Examples of JAXRSServerFactoryBean


Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

                resourceClasses.add(o.getClass());
                map.put(o.getClass(), new SingletonResourceProvider(o));
            }
        }
       
        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
        bean.setAddress("/");
        bean.setResourceClasses(resourceClasses);
        bean.setProviders(providers);
        for (Map.Entry<Class, ResourceProvider> entry : map.entrySet()) {
            bean.setResourceProvider(entry.getKey(), entry.getValue());
        }
        bean.create();
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

    }
   
    @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

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()
       
        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

Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

            createServerFromApplication(applicationClass, servletConfig);
            return;
        }
       
        String splitChar = getParameterSplitChar(servletConfig);
        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
        bean.setBus(getBus());
       
        String address = servletConfig.getInitParameter(SERVICE_ADDRESS_PARAM);
        if (address == null) {
            address = "/";
        }
        bean.setAddress(address);
       
        bean.setStaticSubresourceResolution(getStaticSubResolutionValue(servletConfig));
       
        String modelRef = servletConfig.getInitParameter(USER_MODEL_PARAM);
        if (modelRef != null) {
            bean.setModelRef(modelRef.trim());
        }
        setDocLocation(bean, servletConfig);
        setSchemasLocations(bean, servletConfig);
        setAllInterceptors(bean, servletConfig, splitChar);
        setInvoker(bean, servletConfig);
       
        Map<Class<?>, Map<String, List<String>>> resourceClasses =
            getServiceClasses(servletConfig, modelRef != null, splitChar);
        Map<Class<?>, ResourceProvider> resourceProviders =
            getResourceProviders(servletConfig, resourceClasses);
       
        List<?> providers = getProviders(servletConfig, splitChar);
               
        bean.setResourceClasses(new ArrayList<Class<?>>(resourceClasses.keySet()));
        bean.setProviders(providers);
        for (Map.Entry<Class<?>, ResourceProvider> entry : resourceProviders.entrySet()) {
            bean.setResourceProvider(entry.getKey(), entry.getValue());
        }
        setExtensions(bean, servletConfig);
               
        bean.create();
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

        }
       
        for (String cName : classNames) {
            Application app = createApplicationInstance(cName, servletConfig);
           
            JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app,
                                                ignoreApplicationPath,
                                                getStaticSubResolutionValue(servletConfig));
            String splitChar = getParameterSplitChar(servletConfig);
            setAllInterceptors(bean, servletConfig, splitChar);
            setInvoker(bean, servletConfig);
            setExtensions(bean, servletConfig);
            setDocLocation(bean, servletConfig);
            setSchemasLocations(bean, servletConfig);
           
            bean.setBus(getBus());
            bean.create();
        }
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

    protected ApplicationContext applicationContext;
   
    protected Server createJaxRsServer() {

        JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
        factory.setAddress(getAddress());
        factory.setTransportId(getTransportId());
        factory.setBus(applicationContext.getBean(SpringBus.class));
       
        setRootResources(factory);
        factory.setProviders(getJaxrsProviders());
        factory.setInInterceptors(getInInterceptors());
        factory.setOutInterceptors(getOutInterceptors());
        factory.setOutFaultInterceptors(getOutFaultInterceptors());
        factory.setFeatures(getFeatures());
        finalizeFactorySetup(factory);
        return factory.create();
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

        }

    }
   
    private Server startServer(String address, Class<?> type, Object impl) {
      JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
        factory.setServiceClass(type);
        factory.setAddress(address);
        factory.setResourceProvider(type, new SingletonResourceProvider(impl));
        List<Object> providers = new ArrayList<Object>();
      providers.add(new AegisElementProvider());
      factory.setProviders(providers);
       
      return factory.create();
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

    @Test
    public void testServers() throws Exception {
        ClassPathXmlApplicationContext ctx =
            new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/jaxrs/spring/servers.xml"});
       
        JAXRSServerFactoryBean sfb = (JAXRSServerFactoryBean)ctx.getBean("simple");
        assertEquals("Get a wrong address", "http://localhost:9090/rs", sfb.getAddress());
        assertNotNull("The resource classes should not be null", sfb.getResourceClasses());
        assertEquals("Get a wrong resource class", BookStore.class, sfb.getResourceClasses().get(0));
        assertEquals(new QName("http://books.com", "BookService"),
                     sfb.getServiceName());
       
        sfb = (JAXRSServerFactoryBean)ctx.getBean("inlineServiceBeans");
        assertNotNull("The resource classes should not be null", sfb.getResourceClasses());
        assertEquals("Get a wrong resource class", BookStore.class, sfb.getResourceClasses().get(0));
        assertEquals("Get a wrong resource class",
                     BookStoreSubresourcesOnly.class, sfb.getResourceClasses().get(1));
       
        sfb = (JAXRSServerFactoryBean)ctx.getBean("inlineProvider");
        assertNotNull("The provider should not be null", sfb.getProviders());
        assertEquals("Get a wrong provider size", sfb.getProviders().size(), 3);
        verifyJaxbProvider(sfb.getProviders());
        sfb = (JAXRSServerFactoryBean)ctx.getBean("moduleServer");
        assertNotNull("The resource classes should not be null", sfb.getResourceClasses());
        assertEquals("Get a wrong ResourceClasses size", 1, sfb.getResourceClasses().size());
        assertEquals("Get a wrong resource class", BookStoreNoAnnotations.class,
                     sfb.getResourceClasses().get(0));
       
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

        } catch (Exception e) {
            throw new ServiceException("CXF DOSGi: problem registering CXF HTTP Servlet", e);
        }
        Bus bus = cxf.getBus();

        JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
        factory.setBus(bus);

        List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
        if (resources != null) {
            factory.setModelBeansWithServiceClass(resources, iClass);
            factory.setServiceBeans(serviceBean);
        } else {
            factory.setServiceClass(iClass);
            factory.setResourceProvider(iClass, new SingletonResourceProvider(serviceBean));
        }

        factory.setAddress("/");
        List<Object> providers = JaxRSUtils.getProviders(callingContext, dswContext, sd);
        if (providers != null && providers.size() > 0) {
            factory.setProviders(providers);
        }

        String address = constructAddress(dswContext, contextRoot);

       

        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        try {
            String[] intents = new String[] {
                "HTTP"
            };
           
            // The properties for the EndpointDescription
            Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[] {
                Constants.RS_CONFIG_TYPE
            }, address,intents);
            EndpointDescription endpdDesc = null;
           
           
            Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
            Server server = factory.create();
            registerStopHook(bus, httpService, server, contextRoot, Constants.RS_HTTP_SERVICE_CONTEXT);

            endpdDesc = new EndpointDescription(endpointProps);
            exportRegistration.setServer(server);
           
View Full Code Here

Examples of org.apache.cxf.jaxrs.JAXRSServerFactoryBean

        }

        LOG.info("Creating a " + iClass.getName()
                 + " endpoint via JaxRSPojoConfigurationTypeHandler, address is " + address);

        JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();

        List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
        if (resources != null) {
            factory.setModelBeansWithServiceClass(resources, iClass);
            factory.setServiceBeans(serviceBean);
        } else {
            factory.setServiceClass(iClass);
            factory.setResourceProvider(iClass, new SingletonResourceProvider(serviceBean));
        }

        factory.setAddress(address);
        List<Object> providers = JaxRSUtils.getProviders(callingContext, dswContext, sd);
        if (providers != null && providers.size() > 0) {
            factory.setProviders(providers);
        }


        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        try {
            String[] intents = new String[] {
                "HTTP"
            };

            // The properties for the EndpointDescription
            Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[] {
                Constants.RS_CONFIG_TYPE
            }, address,intents);
            EndpointDescription endpdDesc = null;

            Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
            Server server = factory.create();
            exportRegistration.setServer(server);
            endpdDesc = new EndpointDescription(endpointProps);

            // add the information on the new Endpoint to the export registration
            exportRegistration.setEndpointdescription(endpdDesc);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.