コード例 #1
0
 /**
  * Creates a {@link org.apache.camel.spi.RestConfiguration} instance based on the definition
  *
  * @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 (bindingMode != null) {
     answer.setBindingMode(bindingMode.name());
   }
   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);
   }
   return answer;
 }
コード例 #2
0
 /**
  * Creates a {@link org.apache.camel.spi.RestConfiguration} instance based on the definition
  *
  * @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 (apiComponent != null) {
     answer.setApiComponent(CamelContextHelper.parseText(context, apiComponent));
   }
   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 (apiContextPath != null) {
     answer.setApiContextPath(CamelContextHelper.parseText(context, apiContextPath));
   }
   if (apiContextRouteId != null) {
     answer.setApiContextRouteId(CamelContextHelper.parseText(context, apiContextRouteId));
   }
   if (apiContextIdPattern != null) {
     // special to allow #name# to refer to itself
     if ("#name#".equals(apiComponent)) {
       answer.setApiContextIdPattern(context.getName());
     } else {
       answer.setApiContextIdPattern(CamelContextHelper.parseText(context, apiContextIdPattern));
     }
   }
   if (apiContextListing != null) {
     answer.setApiContextListing(apiContextListing);
   }
   if (contextPath != null) {
     answer.setContextPath(CamelContextHelper.parseText(context, contextPath));
   }
   if (hostNameResolver != null) {
     answer.setRestHostNameResolver(hostNameResolver.name());
   }
   if (bindingMode != null) {
     answer.setBindingMode(bindingMode.name());
   }
   if (skipBindingOnErrorCode != null) {
     answer.setSkipBindingOnErrorCode(skipBindingOnErrorCode);
   }
   if (enableCORS != null) {
     answer.setEnableCORS(enableCORS);
   }
   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);
   }
   if (!apiProperties.isEmpty()) {
     Map<String, Object> props = new HashMap<String, Object>();
     for (RestPropertyDefinition prop : apiProperties) {
       String key = prop.getKey();
       String value = CamelContextHelper.parseText(context, prop.getValue());
       props.put(key, value);
     }
     answer.setApiProperties(props);
   }
   if (!corsHeaders.isEmpty()) {
     Map<String, String> props = new HashMap<String, String>();
     for (RestPropertyDefinition prop : corsHeaders) {
       String key = prop.getKey();
       String value = CamelContextHelper.parseText(context, prop.getValue());
       props.put(key, value);
     }
     answer.setCorsHeaders(props);
   }
   return answer;
 }