Search in sources :

Example 11 with RestConfiguration

use of org.apache.camel.spi.RestConfiguration in project camel by apache.

the class RestletComponent method doStart.

@Override
protected void doStart() throws Exception {
    super.doStart();
    // configure component options
    RestConfiguration config = getCamelContext().getRestConfiguration("restlet", true);
    // configure additional options on spark configuration
    if (config.getComponentProperties() != null && !config.getComponentProperties().isEmpty()) {
        setProperties(this, config.getComponentProperties());
    }
    cleanupConverters(enabledConverters);
    component.start();
}
Also used : RestConfiguration(org.apache.camel.spi.RestConfiguration)

Example 12 with RestConfiguration

use of org.apache.camel.spi.RestConfiguration in project camel by apache.

the class ServletComponent method doStart.

@Override
protected void doStart() throws Exception {
    super.doStart();
    RestConfiguration config = getCamelContext().getRestConfiguration("servlet", true);
    // configure additional options on jetty configuration
    if (config.getComponentProperties() != null && !config.getComponentProperties().isEmpty()) {
        setProperties(this, config.getComponentProperties());
    }
}
Also used : RestConfiguration(org.apache.camel.spi.RestConfiguration)

Example 13 with RestConfiguration

use of org.apache.camel.spi.RestConfiguration in project camel by apache.

the class NettyHttpComponent method doStart.

@Override
protected void doStart() throws Exception {
    super.doStart();
    RestConfiguration config = getCamelContext().getRestConfiguration("netty4-http", true);
    // configure additional options on netty4-http configuration
    if (config.getComponentProperties() != null && !config.getComponentProperties().isEmpty()) {
        setProperties(this, config.getComponentProperties());
    }
}
Also used : RestConfiguration(org.apache.camel.spi.RestConfiguration)

Example 14 with RestConfiguration

use of org.apache.camel.spi.RestConfiguration in project camel by apache.

the class RestSwaggerEndpointTest method shouldDetermineHostFromRestConfiguration.

@Test
public void shouldDetermineHostFromRestConfiguration() {
    assertThat(RestSwaggerEndpoint.hostFrom(null)).isNull();
    final RestConfiguration configuration = new RestConfiguration();
    assertThat(RestSwaggerEndpoint.hostFrom(configuration)).isNull();
    configuration.setScheme("ftp");
    assertThat(RestSwaggerEndpoint.hostFrom(configuration)).isNull();
    configuration.setScheme("http");
    assertThat(RestSwaggerEndpoint.hostFrom(configuration)).isNull();
    configuration.setHost("petstore.swagger.io");
    assertThat(RestSwaggerEndpoint.hostFrom(configuration)).isEqualTo("http://petstore.swagger.io");
    configuration.setPort(80);
    assertThat(RestSwaggerEndpoint.hostFrom(configuration)).isEqualTo("http://petstore.swagger.io");
    configuration.setPort(8080);
    assertThat(RestSwaggerEndpoint.hostFrom(configuration)).isEqualTo("http://petstore.swagger.io:8080");
    configuration.setScheme("https");
    configuration.setPort(80);
    assertThat(RestSwaggerEndpoint.hostFrom(configuration)).isEqualTo("https://petstore.swagger.io:80");
    configuration.setPort(443);
    assertThat(RestSwaggerEndpoint.hostFrom(configuration)).isEqualTo("https://petstore.swagger.io");
}
Also used : RestConfiguration(org.apache.camel.spi.RestConfiguration) Test(org.junit.Test)

Example 15 with RestConfiguration

use of org.apache.camel.spi.RestConfiguration in project camel by apache.

the class RestSwaggerEndpoint method determineBasePath.

String determineBasePath(final Swagger swagger) {
    if (isNotEmpty(basePath)) {
        return basePath;
    }
    final String componentBasePath = component().getBasePath();
    if (isNotEmpty(componentBasePath)) {
        return componentBasePath;
    }
    final String specificationBasePath = swagger.getBasePath();
    if (isNotEmpty(specificationBasePath)) {
        return specificationBasePath;
    }
    final CamelContext camelContext = getCamelContext();
    final RestConfiguration specificConfiguration = camelContext.getRestConfiguration(assignedComponentName, false);
    if (specificConfiguration != null && isNotEmpty(specificConfiguration.getContextPath())) {
        return specificConfiguration.getContextPath();
    }
    final RestConfiguration restConfiguration = camelContext.getRestConfiguration("rest-swagger", true);
    final String restConfigurationBasePath = restConfiguration.getContextPath();
    if (isNotEmpty(restConfigurationBasePath)) {
        return restConfigurationBasePath;
    }
    return RestSwaggerComponent.DEFAULT_BASE_PATH;
}
Also used : CamelContext(org.apache.camel.CamelContext) RestConfiguration(org.apache.camel.spi.RestConfiguration)

Aggregations

RestConfiguration (org.apache.camel.spi.RestConfiguration)36 HashMap (java.util.HashMap)10 Consumer (org.apache.camel.Consumer)10 Endpoint (org.apache.camel.Endpoint)8 CamelContext (org.apache.camel.CamelContext)6 Component (org.apache.camel.Component)3 NoSuchBeanException (org.apache.camel.NoSuchBeanException)3 RouteDefinition (org.apache.camel.model.RouteDefinition)3 Test (org.junit.Test)3 Swagger (io.swagger.models.Swagger)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 NoFactoryAvailableException (org.apache.camel.NoFactoryAvailableException)2 HttpConsumer (org.apache.camel.http.common.HttpConsumer)2 DefaultEndpoint (org.apache.camel.impl.DefaultEndpoint)2 FromDefinition (org.apache.camel.model.FromDefinition)2 InterceptFromDefinition (org.apache.camel.model.InterceptFromDefinition)2 RestDefinition (org.apache.camel.model.rest.RestDefinition)2 FactoryFinder (org.apache.camel.spi.FactoryFinder)2