`EventPublisher.java`
`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 &#064;EventPublisher 36 * <ul> 37 * <li><code>public void addEventListener(java.lang.Object)</code><br/> 38 * &nbsp;&nbsp;&nbsp;&nbsp;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 * &nbsp;&nbsp;&nbsp;&nbsp;registers a Closure as event listener</li> 41 * <li><code>public void addEventListener(java.lang.String, griffon.util.RunnableWithArgs)</code><br/> 42 * &nbsp;&nbsp;&nbsp;&nbsp;registers a Runnable as event listener</li> 43 * <li><code>public void removeEventListener(java.lang.Object)</code><br/> 44 * &nbsp;&nbsp;&nbsp;&nbsp;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 * &nbsp;&nbsp;&nbsp;&nbsp;unregisters a Closure as event listener</li> 47 * <li><code>public void removeEventListener(java.lang.String,griffon.util.RunnableWithArgs)</code><br/> 48 * &nbsp;&nbsp;&nbsp;&nbsp;unregisters a Runnable as event listener</li> 49 * <li><code>public void publishEvent(java.lang.String)</code><br/> 50 * &nbsp;&nbsp;&nbsp;&nbsp;publishes an event in the current thread</li> 51 * <li><code>public void publishEvent(java.lang.String, java.util.List)</code><br/> 52 * &nbsp;&nbsp;&nbsp;&nbsp;publishes an event in the current thread</li> 53 * <li><code>public void publishEventOutsideUI(java.lang.String)</code><br/> 54 * &nbsp;&nbsp;&nbsp;&nbsp;publishes an event outside of the UI thread</li> 55 * <li><code>public void publishEventOutsideUI(java.lang.String, java.util.List)</code><br/> 56 * &nbsp;&nbsp;&nbsp;&nbsp;publishes an event outside of the UI thread</li> 57 * <li><code>public void publishEventAsync(java.lang.String)</code><br/> 58 * &nbsp;&nbsp;&nbsp;&nbsp;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 * &nbsp;&nbsp;&nbsp;&nbsp;publishes an event outside of the publisher's thread</li> 61 * <li><code>public boolean isEventPublishingEnabled()</code><br/> 62 * &nbsp;&nbsp;&nbsp;&nbsp;if events will be published or not</li> 63 * <li><code>public void setEventPublishingEnabled(boolean enabled)</code><br/> 64 * &nbsp;&nbsp;&nbsp;&nbsp;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 }`