Overview | Package | Class | Deprecated | Index | Help
| Griffon 0.9.5-rc2
| FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

## griffon.transform
[Java] Annotation Type Threading

    java.lang.Object
      griffon.transform.Threading

    @Retention(RetentionPolicy.SOURCE)
    @Target({ElementType.METHOD, ElementType.FIELD})
    @GroovyASTTransformationClass("org.codehaus.griffon.ast.ThreadingASTTransformation")
    public @interface Threading

Annotates a method or property.

Annotated elements must follow these rules

- must be a public method or property
- name does not match an event handler
- must pass `griffon.util.GriffonClassUtils.isPlainMethod()` if it's a method
- its value must be a closure (including curried method pointers) if it's a property

This annotation takes `griffon.util.Threading.Policy` as value, with `Threading.Policy.OUTSIDE_UITHREAD` being the default value.

The following snippet exemplifies the compactness of code when the annotation is applied

     import griffon.transform.Threading

     class Sample {
         @Threading
         void doSomethingOutside(String arg) {
             println "Outside $arg"
         }
         @Threading(Threading.Policy.INSIDE_UITHREAD_SYNC)
         void doSomethingInside(String arg) {
             println "Inside $arg"
         }
     }

The equivalent, non-annotated code is

     import griffon.core.UIThreadManager

     class Sample {
         void doSomethingOutside(String arg) {
             UIThreadManager.instance.executeOutside {
                 println "Outside $arg"
             }
         }
         void doSomethingInside(String arg) {
             UIThreadManager.instance.executeSync {
                 println "Inside $arg"
             }
         }
     }

Authors:
  Andres Almiray

See Also:
  Threading.Policy
  org.codehaus.griffon.ast.ThreadingASTTransformation

Since:
  0.9.2

Nested Class Summary
`enum` | `Threading.Policy` Indicates the type of threading management for a method or property.

Optional Element Summary
`null` | `value` @default Policy.OUTSIDE_UITHREAD

Method Summary
`Threading` | `valueOf(String name)` Returns the enum constant of this type with the specified name.
`Threading[]` | `values()` Returns an array containing the constants of this enum type, in the order they are declared.

Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Element Detail

### value

    Threading.Policy value

  @default Policy.OUTSIDE_UITHREAD

Method Detail

### valueOf

    Threading valueOf(String name)

  Returns the enum constant of this type with the specified name.

### values

    Threading[] values()

  Returns an array containing the constants of this enum type, in the order they are declared.

Groovy Documentation