01 /*
02 * Copyright 2009-2012 the original author or authors.
03 *
04 * Licensed under the Apache License, Version 2.0 (the "License");
05 * you may not use this file except in compliance with the License.
06 * You may obtain a copy of the License at
07 *
08 * http://www.apache.org/licenses/LICENSE-2.0
09 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package griffon.transform;
18
19 import org.codehaus.groovy.transform.GroovyASTTransformationClass;
20
21 import java.lang.annotation.ElementType;
22 import java.lang.annotation.Retention;
23 import java.lang.annotation.RetentionPolicy;
24 import java.lang.annotation.Target;
25
26 /**
27 * <p>Annotates a class.</p>
28 *
29 * <p>When annotating a class it indicates that it will become an
30 * event publishing one. The class will have the ability to send
31 * arbitrary events to any listeners that may have been registered
32 * with it. These events are similar to the ones published by
33 * GriffonApplication.</p>
34 *
35 * The following methods will be added to classes annotated with @EventPublisher
36 * <ul>
37 * <li><code>public void addEventListener(java.lang.Object)</code><br/>
38 * registers an event listener of type, Map, Script or bean</li>
39 * <li><code>public void addEventListener(java.lang.String, groovy.lang.Closure)</code><br/>
40 * registers a Closure as event listener</li>
41 * <li><code>public void addEventListener(java.lang.String, griffon.util.RunnableWithArgs)</code><br/>
42 * registers a Runnable as event listener</li>
43 * <li><code>public void removeEventListener(java.lang.Object)</code><br/>
44 * unregisters an event listener of type, Map, Script or bean</li>
45 * <li><code>public void removeEventListener(java.lang.String, groovy.lang.Closure)</code><br/>
46 * unregisters a Closure as event listener</li>
47 * <li><code>public void removeEventListener(java.lang.String,griffon.util.RunnableWithArgs)</code><br/>
48 * unregisters a Runnable as event listener</li>
49 * <li><code>public void publishEvent(java.lang.String)</code><br/>
50 * publishes an event in the current thread</li>
51 * <li><code>public void publishEvent(java.lang.String, java.util.List)</code><br/>
52 * publishes an event in the current thread</li>
53 * <li><code>public void publishEventOutsideUI(java.lang.String)</code><br/>
54 * publishes an event outside of the UI thread</li>
55 * <li><code>public void publishEventOutsideUI(java.lang.String, java.util.List)</code><br/>
56 * publishes an event outside of the UI thread</li>
57 * <li><code>public void publishEventAsync(java.lang.String)</code><br/>
58 * publishes an event outside of the publisher's thread</li>
59 * <li><code>public void publishEventAsync(java.lang.String, java.util.List)</code><br/>
60 * publishes an event outside of the publisher's thread</li>
61 * <li><code>public boolean isEventPublishingEnabled()</code><br/>
62 * if events will be published or not</li>
63 * <li><code>public void setEventPublishingEnabled(boolean enabled)</code><br/>
64 * if events will be published or not</li>
65 * <p/>
66 * </ul>
67 *
68 * @author Andres Almiray
69 * @see org.codehaus.griffon.ast.EventPublisherASTTransformation
70 */
71 @Retention(RetentionPolicy.SOURCE)
72 @Target(ElementType.TYPE)
73 @GroovyASTTransformationClass("org.codehaus.griffon.ast.EventPublisherASTTransformation")
74 public @interface EventPublisher {
75 }
|