* @param context the camel context
* @return the configuration
* @throws Exception is thrown if error creating the configuration
*/
public RestConfiguration asRestConfiguration(CamelContext context) throws Exception {
RestConfiguration answer = new RestConfiguration();
if (component != null) {
answer.setComponent(CamelContextHelper.parseText(context, component));
}
if (scheme != null) {
answer.setScheme(CamelContextHelper.parseText(context, scheme));
}
if (host != null) {
answer.setHost(CamelContextHelper.parseText(context, host));
}
if (port != null) {
answer.setPort(CamelContextHelper.parseInteger(context, port));
}
if (contextPath != null) {
answer.setContextPath(CamelContextHelper.parseText(context, contextPath));
}
if (hostNameResolver != null) {
answer.setRestHostNameResolver(hostNameResolver.name());
}
if (bindingMode != null) {
answer.setBindingMode(bindingMode.name());
}
if (jsonDataFormat != null) {
answer.setJsonDataFormat(jsonDataFormat);
}
if (xmlDataFormat != null) {
answer.setXmlDataFormat(xmlDataFormat);
}
if (!componentProperties.isEmpty()) {
Map<String, Object> props = new HashMap<String, Object>();
for (RestPropertyDefinition prop : componentProperties) {
String key = prop.getKey();
String value = CamelContextHelper.parseText(context, prop.getValue());
props.put(key, value);
}
answer.setComponentProperties(props);
}
if (!endpointProperties.isEmpty()) {
Map<String, Object> props = new HashMap<String, Object>();
for (RestPropertyDefinition prop : endpointProperties) {
String key = prop.getKey();
String value = CamelContextHelper.parseText(context, prop.getValue());
props.put(key, value);
}
answer.setEndpointProperties(props);
}
if (!consumerProperties.isEmpty()) {
Map<String, Object> props = new HashMap<String, Object>();
for (RestPropertyDefinition prop : consumerProperties) {
String key = prop.getKey();
String value = CamelContextHelper.parseText(context, prop.getValue());
props.put(key, value);
}
answer.setConsumerProperties(props);
}
if (!dataFormatProperties.isEmpty()) {
Map<String, Object> props = new HashMap<String, Object>();
for (RestPropertyDefinition prop : dataFormatProperties) {
String key = prop.getKey();
String value = CamelContextHelper.parseText(context, prop.getValue());
props.put(key, value);
}
answer.setDataFormatProperties(props);
}
return answer;
}