Java Code Examples for org.apache.cxf.jaxrs.JAXRSServerFactoryBean#setModelBeans()

The following examples show how to use org.apache.cxf.jaxrs.JAXRSServerFactoryBean#setModelBeans() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXRSClientServerUserResourceAsteriskTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setAddress("http://localhost:" + PORT + CONTEXT);

    UserResource ur = new UserResource();
    ur.setName(BookStoreNoAnnotations.class.getName());
    ur.setPath("/bookstoreNoAnnotations");
    UserOperation op = new UserOperation();
    op.setPath("/books/{id}");
    op.setName("getBook");
    op.setVerb("GET");
    op.setParameters(Collections.singletonList(new Parameter(ParameterType.PATH, "id")));

    UserOperation op2 = new UserOperation();
    op2.setPath("/books/{id}/chapter");
    op2.setName("getBookChapter");
    op2.setParameters(Collections.singletonList(new Parameter(ParameterType.PATH, "id")));

    List<UserOperation> ops = new ArrayList<>();
    ops.add(op);
    ops.add(op2);

    ur.setOperations(ops);

    UserResource ur2 = new UserResource();
    ur2.setName(ChapterNoAnnotations.class.getName());
    UserOperation op3 = new UserOperation();
    op3.setPath("/");
    op3.setName("getItself");
    op3.setVerb("GET");
    ur2.setOperations(Collections.singletonList(op3));

    sf.setModelBeans(ur, ur2);

    String modelRef = "classpath:/org/apache/cxf/systest/jaxrs/resources/resources2.xml";
    sf.setModelRefWithServiceClass(modelRef, BookStoreNoAnnotationsInterface.class);
    sf.setServiceBean(new BookStoreNoAnnotationsImpl());
    server = sf.create();
}
 
Example 2
Source File: JAXRSClientServerUserResourceTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setAddress("http://localhost:" + PORT + "/");

    UserResource ur = new UserResource();
    ur.setName(BookStoreNoAnnotations.class.getName());
    ur.setPath("/bookstoreNoAnnotations");
    UserOperation op = new UserOperation();
    op.setPath("/books/{id}");
    op.setName("getBook");
    op.setVerb("GET");
    op.setParameters(Collections.singletonList(new Parameter(ParameterType.PATH, "id")));

    UserOperation op2 = new UserOperation();
    op2.setPath("/books/{id}/chapter");
    op2.setName("getBookChapter");
    op2.setParameters(Collections.singletonList(new Parameter(ParameterType.PATH, "id")));

    List<UserOperation> ops = new ArrayList<>();
    ops.add(op);
    ops.add(op2);

    ur.setOperations(ops);

    UserResource ur2 = new UserResource();
    ur2.setName(ChapterNoAnnotations.class.getName());
    UserOperation op3 = new UserOperation();
    op3.setPath("/");
    op3.setName("getItself");
    op3.setVerb("GET");
    ur2.setOperations(Collections.singletonList(op3));

    sf.setModelBeans(ur, ur2);

    String modelRef = "classpath:/org/apache/cxf/systest/jaxrs/resources/resources2.xml";
    sf.setModelRefWithServiceClass(modelRef, BookStoreNoAnnotationsInterface.class);
    sf.setServiceBean(new BookStoreNoAnnotationsImpl());
    server = sf.create();
}
 
Example 3
Source File: JAXRSClientServerUserResourceDefaultTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected void run() {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setInvoker(new CustomModelInvoker());
    sf.setProvider(new PreMatchContainerRequestFilter());
    sf.setAddress("http://localhost:" + PORT + "/");
    sf.getServiceFactory().setDefaultModelClass(DefaultResource.class);

    UserResource ur = new UserResource();
    ur.setPath("/default");
    UserOperation op = new UserOperation();
    op.setPath("/books/{id}");
    op.setName("getBook");
    op.setVerb("GET");
    Parameter param = new Parameter(ParameterType.PATH, "id");
    param.setJavaType(Long.class);
    op.setParameters(Collections.singletonList(param));

    UserOperation op2 = new UserOperation();
    op2.setPath("echobook");
    op2.setName("echo");
    op2.setVerb("POST");
    op2.setParameters(Collections.singletonList(new Parameter(ParameterType.REQUEST_BODY, null)));

    UserOperation op3 = new UserOperation();
    op3.setPath("echobookdefault");
    op3.setName("echoDefault");
    op3.setVerb("POST");
    Parameter echoDefaultParam = new Parameter(ParameterType.REQUEST_BODY, null);
    echoDefaultParam.setJavaType(SAXSource.class);
    op3.setParameters(Collections.singletonList(echoDefaultParam));

    List<UserOperation> ops = new ArrayList<>();
    ops.add(op);
    ops.add(op2);
    ops.add(op3);

    ur.setOperations(ops);

    sf.setModelBeans(ur);

    server = sf.create();
}