use of java.util.ArrayList in project camel by apache.
the class DozerTypeConverterLoader method addMapping.
/**
* Registers Dozer <code>BeanMappingBuilder</code> in current mapper instance.
* This method should be called instead of direct <code>mapper.addMapping()</code> invocation for Camel
* being able to register given type conversion.
*
* @param beanMappingBuilder api-based mapping builder
*/
public void addMapping(BeanMappingBuilder beanMappingBuilder) {
if (mapper == null) {
log.warn("No mapper instance provided to " + this.getClass().getSimpleName() + ". Mapping has not been registered!");
return;
}
mapper.addMapping(beanMappingBuilder);
MappingFileData mappingFileData = beanMappingBuilder.build();
TypeConverterRegistry registry = camelContext.getTypeConverterRegistry();
List<ClassMap> classMaps = new ArrayList<ClassMap>();
classMaps.addAll(mappingFileData.getClassMaps());
registerClassMaps(registry, null, mapper, classMaps);
}
use of java.util.ArrayList in project camel by apache.
the class DozerTypeConverterLoader method loadMappings.
private List<ClassMap> loadMappings(CamelContext camelContext, String mapperId, DozerBeanMapper mapper) {
List<ClassMap> answer = new ArrayList<ClassMap>();
// load the class map using the class resolver so we can load from classpath in OSGi
MappingFileReader reader = new MappingFileReader(XMLParserFactory.getInstance());
List<String> mappingFiles = mapper.getMappingFiles();
if (mappingFiles == null) {
return Collections.emptyList();
}
for (String name : mappingFiles) {
URL url = loadMappingFile(camelContext.getClassResolver(), name);
if (url != null) {
MappingFileData data = reader.read(url);
answer.addAll(data.getClassMaps());
}
}
return answer;
}
use of java.util.ArrayList in project camel by apache.
the class ElasticsearchGetSearchDeleteExistsUpdateTest method testMultiGet.
@Test
public void testMultiGet() throws Exception {
//first, INDEX two values
Map<String, String> map = createIndexedData();
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "twitter");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "tweet");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "1");
template.requestBodyAndHeaders("direct:start", map, headers, String.class);
headers.clear();
headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.INDEX);
headers.put(ElasticsearchConstants.PARAM_INDEX_NAME, "facebook");
headers.put(ElasticsearchConstants.PARAM_INDEX_TYPE, "status");
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, "2");
template.requestBodyAndHeaders("direct:start", map, headers, String.class);
headers.clear();
//now, verify MULTIGET
headers.put(ElasticsearchConstants.PARAM_OPERATION, ElasticsearchOperation.MULTIGET);
Item item1 = new Item("twitter", "tweet", "1");
Item item2 = new Item("facebook", "status", "2");
Item item3 = new Item("instagram", "latest", "3");
List<Item> list = new ArrayList<Item>();
list.add(item1);
list.add(item2);
list.add(item3);
MultiGetResponse response = template.requestBodyAndHeaders("direct:start", list, headers, MultiGetResponse.class);
MultiGetItemResponse[] responses = response.getResponses();
assertNotNull("response should not be null", response);
assertEquals("response should contains three multiGetResponse object", 3, response.getResponses().length);
assertEquals("response 1 should contains tweet as type", "tweet", responses[0].getResponse().getType().toString());
assertEquals("response 2 should contains status as type", "status", responses[1].getResponse().getType().toString());
assertFalse("response 1 should be ok", responses[0].isFailed());
assertFalse("response 2 should be ok", responses[1].isFailed());
assertTrue("response 3 should be failed", responses[2].isFailed());
}
use of java.util.ArrayList in project camel by apache.
the class ElsqlEndpoint method doStart.
@Override
protected void doStart() throws Exception {
super.doStart();
ObjectHelper.notNull(resourceUri, "resourceUri", this);
if (elSqlConfig == null && databaseVendor != null) {
elSqlConfig = databaseVendor.asElSqlConfig();
} else if (elSqlConfig == null) {
elSqlConfig = ElSqlDatabaseVendor.Default.asElSqlConfig();
}
// there can be multiple resources
// so we have all this lovely code to turn that into an URL[]
final List<URL> list = new ArrayList<URL>();
final Iterable it = ObjectHelper.createIterable(resourceUri);
for (final Object path : it) {
final URL url = ResourceHelper.resolveMandatoryResourceAsUrl(getCamelContext().getClassResolver(), path.toString());
list.add(url);
}
final URL[] urls = list.toArray(new URL[list.size()]);
elSql = ElSql.parse(elSqlConfig, urls);
}
use of java.util.ArrayList in project camel by apache.
the class ElasticsearchComponent method parseTransportAddresses.
private List<InetSocketTransportAddress> parseTransportAddresses(String ipsString, ElasticsearchConfiguration config) throws UnknownHostException {
if (ipsString == null || ipsString.isEmpty()) {
return null;
}
List<String> addressesStr = Arrays.asList(ipsString.split(ElasticsearchConstants.TRANSPORT_ADDRESSES_SEPARATOR_REGEX));
List<InetSocketTransportAddress> addressesTrAd = new ArrayList<InetSocketTransportAddress>(addressesStr.size());
for (String address : addressesStr) {
String[] split = address.split(ElasticsearchConstants.IP_PORT_SEPARATOR_REGEX);
String hostname;
if (split.length > 0) {
hostname = split[0];
} else {
throw new IllegalArgumentException();
}
Integer port = split.length > 1 ? Integer.parseInt(split[1]) : ElasticsearchConstants.DEFAULT_PORT;
addressesTrAd.add(new InetSocketTransportAddress(InetAddress.getByName(hostname), port));
}
return addressesTrAd;
}
Aggregations