Hi,
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.Code:<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" /> </util:map>
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.Code:@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface TransactonProcessor { /** * Bean ID defined in Spring config * @return */ String beanId(); /** * The transaction Name for which it is applicable * * @return */ String transactionName(); /** * An array of actors for which this is applicable * * @return */ String[] applicableActors(); }
Please help me implement this feature.
Thanks,
Niranjan


Reply With Quote