use of java.util.Map in project camel by apache.
the class Main method getCamelContextMap.
protected Map<String, CamelContext> getCamelContextMap() {
Map<String, CamelContext> answer = Maps.newHashMap();
if (injector != null) {
Set<Map.Entry<Key<?>, Binding<?>>> entries = injector.getBindings().entrySet();
for (Map.Entry<Key<?>, Binding<?>> entry : entries) {
Key<?> key = entry.getKey();
Class<?> keyType = Injectors.getKeyType(key);
if (keyType != null && CamelContext.class.isAssignableFrom(keyType)) {
Binding<?> binding = entry.getValue();
Object value = binding.getProvider().get();
if (value != null) {
CamelContext castValue = CamelContext.class.cast(value);
answer.put(key.toString(), castValue);
}
}
}
}
return answer;
}
use of java.util.Map in project camel by apache.
the class Injectors method tryCloseJitBindings.
private static void tryCloseJitBindings(Closer closer, Injector injector, Class<? extends Annotation> scopeAnnotationToClose, CloseErrors errors) {
Class<? extends Injector> type = injector.getClass();
Field field;
try {
field = type.getDeclaredField("jitBindings");
field.setAccessible(true);
Object bindings = field.get(injector);
if (bindings != null) {
if (bindings instanceof Map) {
Map<Key<?>, BindingImpl<?>> map = (Map<Key<?>, BindingImpl<?>>) bindings;
Set<Entry<Key<?>, BindingImpl<?>>> entries = map.entrySet();
for (Entry<Key<?>, BindingImpl<?>> entry : entries) {
closeBinding(entry.getKey(), entry.getValue(), scopeAnnotationToClose, closer, errors);
}
}
}
} catch (NoSuchFieldException e) {
// ignore - Guice has refactored so we can't access the jit bindings
// System.out.println("No such field! " + e);
} catch (IllegalAccessException e) {
// ignore - Guice has refactored so we can't access the jit bindings
// System.out.println("Failed to access field: " + field +
// ". Reason: " + e);
}
}
use of java.util.Map in project camel by apache.
the class HazelcastMapProducerForSpringTest method testGetAllEmptySet.
@Test
public void testGetAllEmptySet() {
Set<Object> l = new HashSet<Object>();
Map t = new HashMap();
t.put("key1", "value1");
t.put("key2", "value2");
t.put("key3", "value3");
when(map.getAll(anySet())).thenReturn(t);
template.sendBodyAndHeader("direct:getAll", null, HazelcastConstants.OBJECT_ID, l);
String body = consumer.receiveBody("seda:out", 5000, String.class);
verify(map).getAll(l);
assertTrue(body.contains("key1=value1"));
assertTrue(body.contains("key2=value2"));
assertTrue(body.contains("key3=value3"));
}
use of java.util.Map in project camel by apache.
the class HazelcastMapProducerForSpringTest method testGetAllOnlyOneKey.
@Test
public void testGetAllOnlyOneKey() {
Set<Object> l = new HashSet<Object>();
l.add("key1");
Map t = new HashMap();
t.put("key1", "value1");
when(map.getAll(l)).thenReturn(t);
template.sendBodyAndHeader("direct:getAll", null, HazelcastConstants.OBJECT_ID, l);
String body = consumer.receiveBody("seda:out", 5000, String.class);
verify(map).getAll(l);
assertEquals("{key1=value1}", body);
}
use of java.util.Map in project camel by apache.
the class InfinispanProducerTest method publishMapNormalAsync.
@Test
public void publishMapNormalAsync() throws Exception {
template.send("direct:putallasync", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put(KEY_ONE, VALUE_ONE);
map.put(KEY_TWO, VALUE_TWO);
exchange.getIn().setHeader(InfinispanConstants.MAP, map);
}
});
Thread.sleep(100);
assertEquals(2, currentCache().size());
Object value = currentCache().get(KEY_ONE);
assertEquals(VALUE_ONE, value.toString());
value = currentCache().get(KEY_TWO);
assertEquals(VALUE_TWO, value.toString());
}
Aggregations