Annotation PricingPlanAware
Package io.github.isagroup.annotation
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface PricingPlanAware
Annotation automates the feature validation on the server side.
The library also provides an method level annotation called @PricingPlanAware
that receives a string called featureId
as paramater. This feature must exist inside the pricing configuration.
By combining the use of this annotation with the spring's @Transactional
, it is possible to automate feature checking on the service layer of the application.
The annotation performs an evaluation of the feature right after the method is executed. If the evaluation determines that the pricing plan is not being respected, a PricingPlanEvaluationException is thrown, so all the changes made are removed by the @Transactional
annotation rollback. On the other hand, if the evaluation is correct, the changes are commited and the method returns normally.
The following snippet is an example of the use of this annotation inside a demo app service:
import io.github.isagroup.annotations.PricingPlanAware;
// ...
@PricingPlanAware(featureName = "myFeature")
@Transactional(rollbackFor = { PricingPlanEvaluationException.class })
public T myFeatureService(T parameter) {
// Service level logic
}
// ...
Element Details
featureName
String featureName
Name of the feature to perform a evaluation against. Feature names are the one you define in pricing configuration file
Default ""