Annotation Interface ConditionalOnTrajectory


@Retention(RUNTIME) @Target(METHOD) public @interface ConditionalOnTrajectory
This annotation helps to replace service references with new ones. Let us say, we have a service reference in spring defined as "testService" We want to replace this service reference with "testService1" but only if the trajectory id = "t1" You can then use this annotation to accomplish this.

  // original service that needs to be replaced.
  @Bean public TestService testService(){ return new TestServiceImpl(); }
  // replace with this new service only for trajectory id "t1"
  @Bean @ConditionalOnTrajectory(id = "t1", service = "testService")
  public TestService testService1(){ return new TestServiceImpl1();}
 
 The code above replaces all instances of TestServiceImpl with TestServiceImpl1 but will do so only
 for trajectory ID "t1"
Author:
Raja Shankar Kolluru
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The trajectory ID for which the reference is replaced
    The service name that is being replaced with this new service
  • Element Details

    • id

      String id
      The trajectory ID for which the reference is replaced
      Returns:
    • service

      String service
      The service name that is being replaced with this new service
      Returns: