Attribute strategy in Spring Context.xml

75 views
Skip to first unread message

prave...@ebay.com

unread,
May 3, 2017, 5:51:14 PM5/3/17
to PODAM
Hello,

I just started trying PODAM (7.0.5) and it is really great. 

I do not want to annotate my POJOs with PODAM specific annotations. Would it be possible to define all configurable properties for a class type in spring context.xml instead of annotation?

<bean id="podamFactory" class="uk.co.jemos.podam.api.PodamFactoryImpl">
 /*
for a type 'T'
  attribute 'A'  strValue ='v'
  attribute 'B'  nbrElements ='v'
  attribute 'C'  maxValue =100, minValue=1
  attribute 'D'  PodamStrategyValue='PostCodeStrategy.class'
*/
</bean>



I could not find documentation regarding this.

Thanks,
Praveen

Marco Tedone

unread,
May 4, 2017, 1:06:34 AM5/4/17
to po...@googlegroups.com

Look here: https://devopsfolks.github.io/podam/

 

And search for “Defining an attribute-level strategy with DataProviderStrategy”. That should solve your problem.

 

Regards,

M.

--
You received this message because you are subscribed to the Google Groups "PODAM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to podam+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

prave...@ebay.com

unread,
May 4, 2017, 2:55:25 AM5/4/17
to PODAM
Thank you Marco for your response. I looked in to DataProviderStrategy interface. I hope a custom value for an attribute should be resolved through

Class<AttributeStrategy<?>> getStrategyForAnnotation(Class<? extends Annotation> annotationClass);

But this is binded with 'Annotation'. Looks like we cannot get away from using Annotations(either custom or Podom) on a POJO. I am looking for a way to feed in configurations to create a POJO & populate it's attributes from outside of a POJO i.e., either through spring beans or through code. 

Would I still able to do this by implementing DataProvider interface? If so, can you please explain on how I can do this?

Appreciate your help on this,
Praveen

Marco Tedone

unread,
May 4, 2017, 4:28:41 AM5/4/17
to PODAM
If you keep reading that page there's an example with just code. Probably it's called AttributeStrategy

Daniil Ivanov

unread,
May 10, 2017, 9:47:35 AM5/10/17
to PODAM
Hi,

 In Spring configuration you need to do something like this:

<bean id="randomStrategy" class="uk.co.jemos.podam.api.RandomDataProviderStrategyImpl">
</bean>

<bean id="factory" class="uk.co.jemos.podam.api.PodamFactory">
   <property name="strategy" ref="randomStrategy" />
</bean>


Then you need to define your custom TypeManufacturer implementing what you need
and set it to your strategy with DataProviderStrategy.addOrReplaceTypeManufacturer(...)
but as this is not property you cannot do this purely with XML Spring configuration.

You can define all properties you want in a class inherited from
AbstractRandomDataProviderStrategy and then do the rest with Spring XML.

Thanks, Daniil
Reply all
Reply to author
Forward
0 new messages