Package org.apache.cxf.jaxrs

Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean


    }
   
    @Test
    public void testInjectApplicationInPerRequestResource() throws Exception {
        CustomerApplication app = new CustomerApplication();
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setServiceClass(Customer.class);
        sf.setApplication(app);
        sf.setStart(false);
        Server server = sf.create()
       
        @SuppressWarnings("unchecked")
        ThreadLocalProxy<UriInfo> proxy = (ThreadLocalProxy<UriInfo>)app.getUriInfo();
        assertNotNull(proxy);
       
        ClassResourceInfo cri = sf.getServiceFactory().getClassResourceInfo().get(0);
       
        Customer customer = (Customer)cri.getResourceProvider().getInstance(
             new MessageImpl());
       
        assertNull(customer.getApplication1());
View Full Code Here


    }
   
    @Test
    public void testInjectApplicationInSingleton() throws Exception {
        CustomerApplication app = new CustomerApplication();
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        Customer customer = new Customer();
        sf.setServiceBeanObjects(customer);
        sf.setApplication(app);
        sf.setStart(false);
        Server server = sf.create()
        assertSame(app, customer.getApplication1());
        assertSame(app, customer.getApplication2());
        ThreadLocalProxy proxy = (ThreadLocalProxy)app.getUriInfo();
        assertNotNull(proxy);
        invokeCustomerMethod(sf.getServiceFactory().getClassResourceInfo().get(0),
                             customer, server);
        assertSame(app, customer.getApplication2());
        assertTrue(proxy.get() instanceof UriInfo);
    }
View Full Code Here

    }
   
    @Test
    public void testInjectApplicationInPerRequestResource() throws Exception {
        CustomerApplication app = new CustomerApplication();
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setServiceClass(Customer.class);
        sf.setApplication(app);
        sf.setStart(false);
        Server server = sf.create()
       
        ThreadLocalProxy proxy = (ThreadLocalProxy)app.getUriInfo();
        assertNotNull(proxy);
       
        ClassResourceInfo cri = sf.getServiceFactory().getClassResourceInfo().get(0);
       
        Customer customer = (Customer)cri.getResourceProvider().getInstance(
             new MessageImpl());
       
        assertNull(customer.getApplication1());
View Full Code Here

    private static final String POST_REQUEST = "<Customer><name>Jack</name></Customer>";
    private static Server server;

    @BeforeClass
    public static void startServer() {
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setAddress("http://localhost:9002/rest");
        sf.setServiceBean(new CustomerService());
        sf.setStaticSubresourceResolution(true);
        server = sf.create();
    }
View Full Code Here

        }
        cfb.setThreadSafe(true);
    }
   
    protected JAXRSServerFactoryBean newJAXRSServerFactoryBean() {
        return new JAXRSServerFactoryBean();
    }
View Full Code Here

    protected JAXRSClientFactoryBean newJAXRSClientFactoryBean() {
        return new JAXRSClientFactoryBean();
    }

    public JAXRSServerFactoryBean createJAXRSServerFactoryBean() {
        JAXRSServerFactoryBean answer = newJAXRSServerFactoryBean();
        setupJAXRSServerFactoryBean(answer);
        return answer;
    }
View Full Code Here

                resourceClasses.add(o.getClass());
                map.put(o.getClass(), new SingletonResourceProvider(o));
            }
        }
       
        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
        String address = "/";
        if (!ignoreAppPath) {
            ApplicationPath appPath = app.getClass().getAnnotation(ApplicationPath.class);
            if (appPath != null) {
                address = appPath.value();
            }
        }
        if (!address.startsWith("/")) {
            address = "/" + address;
        }
        bean.setAddress(address);
        bean.setStaticSubresourceResolution(staticSubresourceResolution);
        bean.setResourceClasses(resourceClasses);
        bean.setProviders(providers);
        for (Map.Entry<Class<?>, ResourceProvider> entry : map.entrySet()) {
            bean.setResourceProvider(entry.getKey(), entry.getValue());
        }
        bean.setApplication(app);
       
        return bean;
    }
View Full Code Here

    org.apache.cxf.endpoint.Server server;
   
    protected void run() {
        Bus bus = BusFactory.getDefaultBus();
        setBus(bus);
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setBus(bus);
        sf.setResourceClasses(BookStore.class);
       
        List<Object> providers = new ArrayList<Object>();
       
        providers.add(new PreMatchContainerRequestFilter2());
        providers.add(new PreMatchContainerRequestFilter());
        providers.add(new PostMatchContainerResponseFilter());
        providers.add(new PostMatchContainerResponseFilter3());
        providers.add(new PostMatchContainerResponseFilter2());
        providers.add(new CustomReaderInterceptor());
        providers.add(new CustomWriterInterceptor());
        providers.add(new CustomDynamicFeature());
        providers.add(new PostMatchContainerRequestFilter());
        providers.add(new FaultyContainerRequestFilter());
        providers.add(new PreMatchReplaceStreamOrAddress());
        providers.add(new GenericHandlerWriter());
        sf.setProviders(providers);
        sf.setResourceProvider(BookStore.class,
                               new SingletonResourceProvider(new BookStore(), true));
        sf.setAddress("http://localhost:" + PORT + "/");
        server = sf.create();
        BusFactory.setDefaultBus(null);
        BusFactory.setThreadDefaultBus(null);
    }
View Full Code Here

            public String get() {
                return "customerContext";
            }
           
        };
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        Customer customer = new Customer();
        sf.setServiceBeanObjects(customer);
        sf.setProvider(new ContextProvider<CustomerContext>() {
            public CustomerContext createContext(Message message) {
                // TODO Auto-generated method stub
                return contextImpl;
            }
        });
        sf.setStart(false);
        Server s = sf.create()
        assertTrue(customer.getCustomerContext() instanceof ThreadLocalProxy<?>);
        invokeCustomerMethod(sf.getServiceFactory().getClassResourceInfo().get(0),
                             customer, s);
        CustomerContext context = customer.getCustomerContext();
        assertEquals("customerContext", context.get());
    }
View Full Code Here

    }
   
    @Test
    public void testInjectApplicationInSingleton() throws Exception {
        CustomerApplication app = new CustomerApplication();
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        Customer customer = new Customer();
        sf.setServiceBeanObjects(customer);
        sf.setApplication(app);
        sf.setStart(false);
        Server server = sf.create()
        assertSame(app, customer.getApplication1());
        assertSame(app, customer.getApplication2());
        @SuppressWarnings("unchecked")
        ThreadLocalProxy<UriInfo> proxy = (ThreadLocalProxy<UriInfo>)app.getUriInfo();
        assertNotNull(proxy);
        invokeCustomerMethod(sf.getServiceFactory().getClassResourceInfo().get(0),
                             customer, server);
        assertSame(app, customer.getApplication2());
        assertTrue(proxy.get() instanceof UriInfo);
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.