|
Groovy 2.2.2 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
java.lang.Objectgroovy.lang.Singleton
@Retention(RetentionPolicy.SOURCE) @Target({ElementType.TYPE}) @GroovyASTTransformationClass("org.codehaus.groovy.transform.SingletonASTTransformation") public @interface Singleton
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:
@Singleton
annotation becomes merely documentation)Optional Element Summary | |
---|---|
boolean |
lazy
@default false
|
java.lang.String |
property
@default "instance"
|
boolean |
strict
@default true
|
Method Summary |
---|
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Element Detail |
---|
public boolean lazy
public String property
public boolean strict
Copyright © 2003-2013 The Codehaus. All rights reserved.