use of org.apache.camel.component.directvm.DirectVmComponent in project camel by apache.
the class DirectVmComponentConfigurationAndDocumentationTest method testComponentConfiguration.
@Test
public void testComponentConfiguration() throws Exception {
DirectVmComponent comp = context.getComponent("direct-vm", DirectVmComponent.class);
EndpointConfiguration conf = comp.createConfiguration("direct-vm:foo?block=false");
assertEquals("false", conf.getParameter("block"));
ComponentConfiguration compConf = comp.createComponentConfiguration();
String json = compConf.createParameterJsonSchema();
assertNotNull(json);
assertTrue(json.contains("\"name\": { \"kind\": \"path\", \"displayName\": \"Name\", \"group\": \"common\", \"required\": true, \"type\": \"string\""));
assertTrue(json.contains("\"timeout\": { \"kind\": \"parameter\", \"displayName\": \"Timeout\", \"group\": \"producer\", \"label\": \"producer\", \"type\": \"integer\""));
}
use of org.apache.camel.component.directvm.DirectVmComponent in project camel by apache.
the class DirectVmComponentAutoConfiguration method configureDirectVmComponent.
@Lazy
@Bean(name = "direct-vm-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(DirectVmComponent.class)
public DirectVmComponent configureDirectVmComponent(CamelContext camelContext, DirectVmComponentConfiguration configuration) throws Exception {
DirectVmComponent component = new DirectVmComponent();
component.setCamelContext(camelContext);
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null, false);
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
Class<?> paramClass = value.getClass();
if (paramClass.getName().endsWith("NestedConfiguration")) {
Class nestedClass = null;
try {
nestedClass = (Class) paramClass.getDeclaredField("CAMEL_NESTED_CLASS").get(null);
HashMap<String, Object> nestedParameters = new HashMap<>();
IntrospectionSupport.getProperties(value, nestedParameters, null, false);
Object nestedProperty = nestedClass.newInstance();
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters);
entry.setValue(nestedProperty);
} catch (NoSuchFieldException e) {
}
}
}
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters);
return component;
}
Aggregations