In my current project, we create a mapping between the actors and business processor class (in a HashMap defined inside Spring config as a bean). The term actor is not used in a generic sense, rather specific to our application. An example is shown below:
Here, EMEA_MANAGER is the actor ID in our application and ORDER_CREATE is the transaction that the actor wants to invoke. There must be a bean with ID "emeaManagerOrderCreateBusinessProcessor" which defines the class which performs this transaction.
<util:map id="businessProcessorMapping" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java.lang.String">
<entry key="EMEA_MANAGER_ORDER_CREATE" value="orderCreateBusinessProcessor" />
<entry key="APAC_MANAGER_ORDER_CREATE" value="apacManagerOrderCreateBusinessProcessor" />
Now, as the number of transactions are growing in our application, it is difficult to maintain such a mapping hash map. Also, developers tend to do mistakes in defining the mapping keys, which causes runtime issues.
To avoid this, I was thinking to introduce a custom annotation
What I want is, which spring application context is loaded at the beginning of the application deployment, spring should read all the classes inside a package (and its sub package) and scan this annotation and prepares this hash map inside the spring context so that an appropriate businessProcessor can be picked at the run time.
public @interface TransactonProcessor
* Bean ID defined in Spring config
* The transaction Name for which it is applicable
* An array of actors for which this is applicable
Please help me implement this feature.