Skip to content

Package: ListensTo

ListensTo

Coverage

1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * TheseFoolishThings: Miscellaneous utilities
5: * http://tidalwave.it/projects/thesefoolishthings
6: *
7: * Copyright (C) 2009 - 2025 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/thesefoolishthings-src
22: * git clone https://github.com/tidalwave-it/thesefoolishthings-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.messagebus.annotation;
27:
28: import java.lang.annotation.Documented;
29: import java.lang.annotation.ElementType;
30: import java.lang.annotation.Retention;
31: import java.lang.annotation.RetentionPolicy;
32: import java.lang.annotation.Target;
33:
34: /***************************************************************************************************************************************************************
35: *
36: * This annotation is used to write simpler code which uses a message bus. With the proper support, code that receives
37: * messages can be written as simple methods such as:
38: *
39: * <pre>
40: * private void onMessage (final @ListenTo Message message)
41: * {
42: * ...
43: * }
44: * </pre>
45: *
46: * Note that this annotation doesn't support any further semantics; for instance, <code>message</code> could be null or
47: * not, in function of the message bus implementation; nor you can make any assumption on the threading. The exact
48: * semantics are defined by further annotations (on the class containing the listener method), or by the build context
49: * (e.g. an annotation processor, AspectJ, etc...).
50: *
51: * Specific support must be used in order to have this annotation working. For instance, an annotation processor, or
52: * some facility which scans classes at runtime, or {@link it.tidalwave.messagebus.MessageBusHelper}.
53: *
54: * @author Fabrizio Giudici
55: *
56: **************************************************************************************************************************************************************/
57: @Retention(RetentionPolicy.RUNTIME)
58: @Target(ElementType.PARAMETER)
59: @Documented
60: public @interface ListensTo
61: {
62: }