forked from ringcentral/jagger8
-
Notifications
You must be signed in to change notification settings - Fork 0
File provider
Nikolay Musienko edited this page Jun 3, 2013
·
3 revisions
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:
- 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();
}
}- Create bean with this class
<beans:bean id="stringCreator" class="com.griddynamics.jagger.providers.creators.StringCreator"/>- Create component
query-providerwith type sub-componentobject-creatorwith typeobject-creator-refand set attributerefto 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>