Skip to content
Nikolay Musienko edited this page Jun 3, 2013 · 3 revisions

This provider reads line-separated file of string values

You can use this component by setting type to endpoint-provider-file

This component requires attribute path.

<endpoint-provider id="endpointProvider" xsi:type="endpoint-provider-file" path="endpoints.txt"/>

In this case will be used line-separated values of strings You can specify delimeter and wrapper for values, to create custom objects. Wrapper must implements interface "ObjectCreator". To implement this you must do:

  1. Create class which implements interface "ObjectCreator":
package com.griddynamics.jagger.providers.creators;

import com.google.common.base.Preconditions;

public class StringCreator implements ObjectCreator<String> {

   @Override
   public String createObject(final String... strings) {
       Preconditions.checkNotNull(strings);
       Preconditions.checkState(strings.length > 0);
       if(strings.length == 1) {
           return strings[0];
       }
       return buildString(strings);
   }

   @Override
   public void setHeader(final String[] header) {
   }

   private String buildString(final String[] strings) {
       StringBuilder builder = new StringBuilder();
       for (String s: strings){
           builder.append(s);
       }
       return builder.toString();
   }
}
  1. Create bean with this class
   <beans:bean id="stringCreator" class="com.griddynamics.jagger.providers.creators.StringCreator"/>
  1. Create component query-provider with type sub-component object-creator with type object-creator-ref and set attribute ref to creator bean name.
<query-provider id="fileQueryProvider" xsi:type="query-provider-file" path="queries.txt" delimeter=";">
   <object-creator xsi:type="object-creator-ref" ref="stringCreator"/>
</query-provider>

Clone this wiki locally