Groovy Documentation

[Groovy] Class Utils

java.lang.Object
  Utils

class Utils

This class contains static helper methods which are used more than once in this plugin.

Authors:
Thomas P. Fuller


Constructor Summary
Utils()

 
Method Summary
static void addListener(org.infinispan.Cache cache, groovy.lang.Closure closure)

A method that adds the listener instance which is returned from the closure param.

static void addListener(org.infinispan.manager.EmbeddedCacheManager embeddedCacheManager, groovy.lang.Closure closure)

A method that adds the listener instance which is returned from the call to the closure param.

static void assertNotAnInstanceOf(java.lang.Class type, java.lang.Object object)

Throws an exception when the object is an instance of the type; this method sets the message to a default value.

static void assertNotAnInstanceOf(java.lang.Class type, java.lang.Object object, java.lang.String message)

Throws an exception if the object is an instance of the specified type.

static void assertNotNull(groovy.lang.Closure closure)

Checks that the closure is not null -- if it is, a null pointer exception is thrown.

static java.lang.Object callClosure(groovy.lang.GroovyObject delegate, groovy.lang.Closure closure)

// * // * @return //

Parameters:
targetClass // - *
mustImplement // - *
action // - *

static java.lang.Object callClosure(groovy.lang.GroovyObject delegate, java.lang.String configText, java.lang.String target)

Method is used to configure the application via the InfinispanConfig.groovy script.

static java.util.Set findAllListeners(org.infinispan.notifications.Listenable listenable, groovy.lang.Closure filter)

Method iterates over all listeners registered with the instance of listenable and returns all listeners which the filter applies to.

static java.util.Set findAllListeners(java.util.Set listeners, groovy.lang.Closure filter)

A method which returns a list of BaseListeners that were filtered from the set of listeners.

static boolean implementsInterface(java.lang.Class targetClass, java.lang.Class mustImplement)

A method which is used to determine if the targetClass implements the given interface.

static void removeListener(org.infinispan.notifications.Listenable listenable, java.lang.Class synchronousListenerClass, java.lang.Class asynchronousListenerClass, boolean synchronous, groovy.lang.Closure closure)

Convenience method that iterates over the listenable's listeners and removes either the synchronous or asynchronous listener associated with the closure param.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Constructor Detail

Utils

Utils()


 
Method Detail

addListener

static void addListener(org.infinispan.Cache cache, groovy.lang.Closure closure)
A method that adds the listener instance which is returned from the closure param.
Parameters:
closure - The closure must return an instance of the listener being added.


addListener

static void addListener(org.infinispan.manager.EmbeddedCacheManager embeddedCacheManager, groovy.lang.Closure closure)
A method that adds the listener instance which is returned from the call to the closure param.
Parameters:
embeddedCacheManager - The target the listener will be added to.
closure - The closure must return an instance of the listener being added.


assertNotAnInstanceOf

static void assertNotAnInstanceOf(java.lang.Class type, java.lang.Object object)
Throws an exception when the object is an instance of the type; this method sets the message to a default value.
throws:
GrailsInfinispanException If object is an instance of the type.
deprecated:
This is dead code and will be removed in the near future.
Parameters:
type - The type to watch for.
object - The object to check.
See Also:
assertNotAnInstanceOf(Class, Object, String)


assertNotAnInstanceOf

static void assertNotAnInstanceOf(java.lang.Class type, java.lang.Object object, java.lang.String message)
Throws an exception if the object is an instance of the specified type.
throws:
GrailsInfinispanException If object is an instance of the type.
deprecated:
This is dead code and will be removed in the near future.
Parameters:
type - The type being watched for.
object - The object to check.
message - The message to be included with the exception.


assertNotNull

static void assertNotNull(groovy.lang.Closure closure)
Checks that the closure is not null -- if it is, a null pointer exception is thrown.
throws:
NullPointerException If the closure is null.
Parameters:
closure - The closure.


callClosure

static java.lang.Object callClosure(groovy.lang.GroovyObject delegate, groovy.lang.Closure closure)
// * // *
Parameters:
targetClass // - *
mustImplement // - *
action // - *
Returns:
//


callClosure

static java.lang.Object callClosure(groovy.lang.GroovyObject delegate, java.lang.String configText, java.lang.String target)
Method is used to configure the application via the InfinispanConfig.groovy script.
Parameters:
delegate - The entry-point delegate for the plugin's domain-specific configuration language.
configText - The text read in via the ConfigSlurper.
target - The variable required -- ie. "infinispan".


findAllListeners

static java.util.Set findAllListeners(org.infinispan.notifications.Listenable listenable, groovy.lang.Closure filter)
Method iterates over all listeners registered with the instance of listenable and returns all listeners which the filter applies to.
todo:
Change the return type to Set.
Parameters:
listenable - An instance of org.infinispan.notifications.Listenable.
filter - A closure which returns the listener if the filter applies.
Returns:
A set of listeners for which the filter applies.


findAllListeners

static java.util.Set findAllListeners(java.util.Set listeners, groovy.lang.Closure filter)
A method which returns a list of BaseListeners that were filtered from the set of listeners. Note that the return type could be a list of any objects, however this plugin helps the user register closures as listeners and we facilitate this via classes that extend from BaseListener.
todo:
Change the return type to Set.
Parameters:
listeners - The set of all listeners.
filter - A closure that is used to find a subset of listeners.
Returns:
The subset of listeners as a set of BaseListeners.


implementsInterface

static boolean implementsInterface(java.lang.Class targetClass, java.lang.Class mustImplement)
A method which is used to determine if the targetClass implements the given interface. Note that this method will return false if the target class does not implement any interfaces.
Parameters:
targetClass - The target class being inspected.
targetInterface - The interface that the target class may or may not implement.
Returns:
True if the target class implements the interface, false otherwise.


removeListener

static void removeListener(org.infinispan.notifications.Listenable listenable, java.lang.Class synchronousListenerClass, java.lang.Class asynchronousListenerClass, boolean synchronous, groovy.lang.Closure closure)
Convenience method that iterates over the listenable's listeners and removes either the synchronous or asynchronous listener associated with the closure param.
Parameters:
listenable - An instance of org.infinispan.notifications.Listenable.
synchronousListenerClass - The synchronous target class type to be removed.
asynchronousListenerClass - The asynchronous target class type to be removed.
synchronous - If true the closure associated with instances of the synchronousListenerClass will be removed, otherwise the closure associated with instances of the asynchronousListenerClass will be removed.
closure - The closure being removed.


 

Groovy Documentation