当前位置: 首页>>代码示例>>Java>>正文


Java RestBindingMode类代码示例

本文整理汇总了Java中org.apache.camel.model.rest.RestBindingMode的典型用法代码示例。如果您正苦于以下问题:Java RestBindingMode类的具体用法?Java RestBindingMode怎么用?Java RestBindingMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RestBindingMode类属于org.apache.camel.model.rest包,在下文中一共展示了RestBindingMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
public void configure() throws Exception {

    // configure we want to use spark-rest on port 8080 as the component for the rest DSL
    // and for the swagger api-doc as well
    restConfiguration().component("spark-rest").apiContextPath("api-doc").port(8080)
        // and we enable json binding mode
        .bindingMode(RestBindingMode.json)
        // and output using pretty print
        .dataFormatProperty("prettyPrint", "true");

    // this user REST service is json only
    rest("/user").consumes("application/json").produces("application/json")

        .get("/view/{id}").outType(User.class)
            .to("bean:userService?method=getUser(${header.id})")

        .get("/list").outTypeList(User.class)
            .to("bean:userService?method=listUsers")

        .put("/update").type(User.class).outType(User.class)
            .to("bean:userService?method=updateUser");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:UserRouteBuilder.java

示例2: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use netty-http on localhost with the given port
            // and enable auto binding mode
            restConfiguration().component("netty-http").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                .post("new").type(UserJaxbPojo.class)
                    .to("mock:input");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:RestNettyHttpPostJsonJaxbPojoTest.java

示例3: configure

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
public void configure() throws Exception {

    // use jetty for rest service
    restConfiguration("jetty").port("{{port}}").contextPath("api")
            // turn on json binding
            .bindingMode(RestBindingMode.json)
            // turn off binding error on empty beans
            .dataFormatProperty("disableFeatures", "FAIL_ON_EMPTY_BEANS")
            // enable swagger api documentation
            .apiContextPath("api-doc")
            .enableCORS(true);

    // define the rest service
    rest("/cart").consumes("application/json").produces("application/json")
        // get returns List<CartDto>
        .get().outType(CartDto[].class).description("Returns the items currently in the shopping cart")
            .to("bean:cart?method=getItems")
        // get accepts CartDto
        .post().type(CartDto.class).description("Adds the item to the shopping cart")
            .to("bean:cart?method=addItem")
        .delete().description("Removes the item from the shopping cart")
            .param().name("itemId").description("Id of item to remove").endParam()
            .to("bean:cart?method=removeItem");
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:26,代码来源:CartRoute.java

示例4: configure

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
public void configure() throws Exception {
	/************************
	 * Rest configuration. There should be only one in a CamelContext
	 ************************/
	restConfiguration().component("servlet") //Requires "CamelServlet" to be registered
		.bindingMode(RestBindingMode.json)
		//Customize in/out Jackson objectmapper, see JsonDataFormat. Two different instances): json.in.*, json.out.*
		.dataFormatProperty("json.in.moduleClassNames", "com.fasterxml.jackson.datatype.jsr310.JavaTimeModule")
		.dataFormatProperty("json.out.include", "NON_NULL")
		.dataFormatProperty("json.out.disableFeatures", "WRITE_DATES_AS_TIMESTAMPS")
		.dataFormatProperty("json.out.moduleClassNames", "com.fasterxml.jackson.datatype.jsr310.JavaTimeModule")
		
		
		//Enable swagger endpoint. It's actually served by a Camel route
		.apiContextPath("/swagger") //swagger endpoint path; Final URL: Camel path + apiContextPath: /api/swagger
		.apiContextRouteId("swagger") //id of route providing the swagger endpoint
		
		.contextPath("/api") //base.path swagger property; use the mapping URL set for CamelServlet camel.component.servlet.mapping.contextPath
		.apiProperty("api.title", "Example REST api")
		.apiProperty("api.version", "1.0")
		//.apiProperty("schemes", "" ) //Setting empty string as scheme to support relative urls
		.apiProperty("schemes", serverProperties.getSsl() != null && serverProperties.getSsl().isEnabled() ? "https" : "http" )
		.apiProperty("host", "") //Setting empty string as host so swagger-ui make relative url calls. By default 0.0.0.0 is used
		;
}
 
开发者ID:bszeti,项目名称:camel-springboot,代码行数:27,代码来源:RestConfiguration.java

示例5: configure

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
public void configure() throws Exception {
    restConfiguration()
        .contextPath("/rest/api")
        .apiContextPath("/api-doc")
        .apiProperty("api.title", "Camel REST API")
        .apiProperty("api.version", "1.0")
        .apiProperty("cors", "true")
        .apiContextRouteId("doc-api")
        .component("undertow")
        .bindingMode(RestBindingMode.json);

    rest("/books").description("Books REST service")
        .get("/").description("The list of all the books")
            .route()
                .toF("jpa:%s?nativeQuery=select distinct description from orders", Order.class.getName())
            .endRest()
        .get("order/{id}").description("Details of an order by id")
            .route()
                .toF("jpa:%s?consumeDelete=false&parameters=#queryParameters&nativeQuery=select * from orders where id = :id", Order.class.getName())
                .process("jpaResultProcessor")
            .endRest();
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel-examples,代码行数:23,代码来源:RestAPIRouteBuilder.java

示例6: configure

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
public void configure() {

    // configure to use jetty on localhost with the given port and enable auto binding mode
    restConfiguration()
            .component("jetty")
            .host("0.0.0.0").port(9090)
            .bindingMode(RestBindingMode.json)
            .dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES, ADJUST_DATES_TO_CONTEXT_TIME_ZONE")
            .dataFormatProperty("json.in.enableFeatures", "FAIL_ON_NUMBERS_FOR_ENUMS, USE_BIG_DECIMAL_FOR_FLOATS")
            .apiContextPath("/api-doc")
            .apiProperty("api.title", "API")
            .apiProperty("api.version", "1.0.0")
            .apiProperty("cors", "true");

    rest("/say")
            .description("Say hello")
            .consumes("application/json")
            .produces("application/json")
            .get("/hello")
            .route()
            .routeId("Hello REST")
            .transform().constant("Say hello to REST!");
}
 
开发者ID:TerrenceMiao,项目名称:camel-spring,代码行数:25,代码来源:HelloRouter.java

示例7: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use netty-http on localhost with the given port
            // and enable auto binding mode
            restConfiguration().component("netty-http").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                .post("new").typeList(UserPojo.class)
                    .to("mock:input");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:RestNettyHttpPostJsonPojoListTest.java

示例8: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use netty-http on localhost with the given port
            // and enable auto binding mode
            restConfiguration().component("netty-http").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                .post("new").type(UserPojo.class)
                    .to("mock:input");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:RestNettyHttpPostJsonPojoTest.java

示例9: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use netty-http on localhost with the given port
            // and enable auto binding mode
            restConfiguration().component("netty-http").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                // just return the default country here
                .get("lives").to("direct:start")
                .post("lives").type(UserPojo.class).outType(CountryPojo.class)
                    .route()
                    .bean(new UserService(), "livesWhere");
            
            CountryPojo country = new CountryPojo();
            country.setIso("EN");
            country.setCountry("England");
            from("direct:start").transform().constant(country);
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:RestNettyHttpPojoInOutTest.java

示例10: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use servlet and enable auto binding mode
            restConfiguration().component("servlet").bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                // just return the default country here
                .get("lives").to("direct:start")
                .post("lives").type(UserPojo.class).outType(CountryPojo.class)
                    .route()
                    .bean(new UserService(), "livesWhere");
            
            CountryPojo country = new CountryPojo();
            country.setIso("EN");
            country.setCountry("England");
            from("direct:start").transform().constant(country);
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:RestServletPojoInOutTest.java

示例11: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use netty4-http on localhost with the given port
            // and enable auto binding mode
            restConfiguration().component("netty4-http").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                .post("new").type(UserJaxbPojo.class)
                    .to("mock:input");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:RestNettyHttpPostJsonJaxbPojoTest.java

示例12: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use netty4-http on localhost with the given port
            // and enable auto binding mode
            restConfiguration().component("netty4-http").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                .post("new").typeList(UserPojo.class)
                    .to("mock:input");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:RestNettyHttpPostJsonPojoListTest.java

示例13: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use netty4-http on localhost with the given port
            // and enable auto binding mode
            restConfiguration().component("netty4-http").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                .post("new").type(UserPojo.class)
                    .to("mock:input");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:RestNettyHttpPostJsonPojoTest.java

示例14: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use netty4-http on localhost with the given port
            // and enable auto binding mode
            restConfiguration().component("netty4-http").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                // just return the default country here
                .get("lives").to("direct:start")
                .post("lives").type(UserPojo.class).outType(CountryPojo.class)
                    .route()
                    .bean(new UserService(), "livesWhere");
        
            CountryPojo country = new CountryPojo();
            country.setIso("EN");
            country.setCountry("England");
            
            from("direct:start").transform().constant(country);
            
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:RestNettyHttpPojoInOutTest.java

示例15: createRouteBuilder

import org.apache.camel.model.rest.RestBindingMode; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // configure to use undertow on localhost with the given port
            // and enable auto binding mode
            restConfiguration().component("undertow").host("localhost").port(getPort()).bindingMode(RestBindingMode.auto);

            // use the rest DSL to define the rest services
            rest("/users/")
                // just return the default country here
                .get("lives").to("direct:start")
                .post("lives").type(UserPojo.class).outType(CountryPojo.class)
                    .route()
                    .bean(new UserService(), "livesWhere");
        
            CountryPojo country = new CountryPojo();
            country.setIso("EN");
            country.setCountry("England");
            
            from("direct:start").transform().constant(country);
            
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:RestUndertowHttpPojoInOutTest.java


注:本文中的org.apache.camel.model.rest.RestBindingMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。