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 import jakarta.annotation.Nonnull;
34
35 /***************************************************************************************************************************************************************
36 *
37 * Designates a class as a simple subscriber of a message bus. This makes it possible to avoid plumbing code for
38 * subscribing to topics and use instead {@link ListensTo} with {@link it.tidalwave.messagebus.MessageBusHelper}.
39 * An optional {@link #source()} parameter can be specified to choose a message bus for systems where more than one are
40 * available.
41 *
42 * @author Fabrizio Giudici
43 *
44 **************************************************************************************************************************************************************/
45 @Retention(RetentionPolicy.RUNTIME)
46 @Target(ElementType.TYPE)
47 @Documented
48 public @interface SimpleMessageSubscriber
49 {
50 public static final String DEFAULT_SOURCE = "applicationMessageBus";
51
52 /***********************************************************************************************************************************************************
53 * The name of the source that this annotation refers to.
54 *
55 * @return the source name
56 **********************************************************************************************************************************************************/
57 @Nonnull
58 String source() default DEFAULT_SOURCE;
59 }