Top Description Methods
groovy.lang

public @Interface Singleton

extends Annotation
Annotations
@Documented
@Retention:SOURCE
@Target:TYPE
@GroovyASTTransformationClass:SingletonASTTransformation
Imports
org.codehaus.groovy.transform.GroovyASTTransformationClass, java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target

Class annotation to make a singleton class. The singleton is obtained through normal property access using the singleton property (defaults to "instance"). Such classes can be initialized during normal static initialization of the class or lazily (on first access). To make the singleton lazy use @Singleton(lazy=true). Lazy singletons are implemented with double-checked locking and a volatile backing field. By default, no explicit constructors are allowed. To create one or more explicit constructors use @Singleton(strict=false). This could be used to:

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

if this singleton should be lazy
lazy
()

public String

Returns:

the singleton property name
property
()

public boolean

Returns:

if this singleton should have strict semantics
strict
()

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

lazyback to summary
public boolean lazy()
Returns:boolean

if this singleton should be lazy

propertyback to summary
public String property()
Returns:String

the singleton property name

strictback to summary
public boolean strict()
Returns:boolean

if this singleton should have strict semantics