Package org.apache.cxf.endpoint

Examples of org.apache.cxf.endpoint.ServerImpl


    }
   
    protected void doPublish(String addr) {
        checkPublishPermission();
       
        ServerImpl serv = getServer(addr);
        if (addr != null) {
            serv.getEndpoint().getEndpointInfo().setAddress(addr);
        }
        serv.start();
    }
View Full Code Here


       
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("contextMatchStrategy", "stem");
        sf.setProperties(props);
       
        ServerImpl svr = (ServerImpl) sf.create();

        URIMapper mapper = (URIMapper) svr.getEndpoint().getService().get(URIMapper.class.getName());
        assertNotNull(mapper);
       
        BindingOperationInfo bop = mapper.getOperation("/customers", "GET", null);
        assertNotNull(bop);
        assertEquals("getCustomers", bop.getName().getLocalPart());
       
        bop = mapper.getOperation("/customers", "POST", null);
        assertNotNull(bop);
        assertEquals("addCustomer", bop.getName().getLocalPart());
       
        bop = mapper.getOperation("/customers/123", "GET", null);
        assertNotNull(bop);
        assertEquals("getCustomer", bop.getName().getLocalPart());
       
        bop = mapper.getOperation("/customers/123", "PUT", null);
        assertNotNull(bop);
        assertEquals("updateCustomer", bop.getName().getLocalPart());
       
        bop = mapper.getOperation("/customers/details/123", "GET", null);
        assertNotNull(bop);
        assertEquals("getSomeDetails", bop.getName().getLocalPart());
       
        // TEST POST/GETs
       
        Document res = get("http://localhost:9001/foo/customers");
        assertNotNull(res);

        addNamespace("c", "http://cxf.apache.org/jra");
        assertValid("/c:customers", res);
        assertValid("/c:customers/c:customer/c:id[text()='123']", res);
        assertValid("/c:customers/c:customer/c:name[text()='Dan Diephouse']", res);
       
        res = get("http://localhost:9001/foo/customers/123");
        assertNotNull(res);
       
        assertValid("/c:customer", res);
        assertValid("/c:customer/c:id[text()='123']", res);
        assertValid("/c:customer/c:name[text()='Dan Diephouse']", res);
       
        // Try invalid customer
        res = get("http://localhost:9001/foo/customers/0", 500);
        assertNotNull(res);
       
        assertValid("//c:CustomerNotFoundDetails", res);
       
        res = put("http://localhost:9001/foo/customers/123", "update.xml");
        assertNotNull(res);
       
        assertValid("/c:updateCustomer", res);
       
        res = post("http://localhost:9001/foo/customers", "add.xml");
        assertNotNull(res);
       
        assertValid("/c:addCustomer", res);

        // Get the updated document
        res = get("http://localhost:9001/foo/customers/123");
        assertNotNull(res);
       
        assertValid("/c:customer", res);
        assertValid("/c:customer/c:id[text()='123']", res);
        assertValid("/c:customer/c:name[text()='Danno Manno']", res);
       
        svr.stop();
    }
View Full Code Here

       
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("Content-Type", "text/plain");
        sf.setProperties(props);
       
        ServerImpl svr = (ServerImpl) sf.create();
       
        URL url = new URL("http://localhost:9001/foo/customers/123");
        HttpURLConnection c = (HttpURLConnection)url.openConnection();
        c.setRequestMethod("GET");
       
        assertEquals("text/plain", c.getContentType());

        c.disconnect();
       
        url = new URL("http://localhost:9001/foo/customers/bleh");
        c = (HttpURLConnection)url.openConnection();
        c.setRequestMethod("GET");
       
        String ct = c.getContentType();
        assertTrue(ct.startsWith("text/plain"));

        svr.stop();
    }
View Full Code Here

        sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
        sf.setServiceBean(new TestService());
        sf.getServiceFactory().setWrapped(false);
        sf.setAddress("http://localhost:9001/test/");

        ServerImpl svr = (ServerImpl) sf.create();
       
        URL url = new URL("http://localhost:9001/test/topics/123");
        HttpURLConnection c = (HttpURLConnection)url.openConnection();
        c.setRequestMethod("GET");
       
        assertEquals("text/xml; charset=utf-8", c.getContentType());
       
        Document doc = DOMUtils.readXml(c.getErrorStream());
        assertValid("//*[text()='You can not map a URI parameter to a "
                    + "simple type when in unwrapped mode!']", doc);

        svr.stop();
    }
View Full Code Here

        sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
        sf.setServiceBean(new TestService());
        sf.getServiceFactory().setWrapped(false);
        sf.setAddress("http://localhost:9001/test/");

        ServerImpl svr = (ServerImpl) sf.create();
       
        URL url = new URL("http://localhost:9001/test/rest/foo");
        HttpURLConnection c = (HttpURLConnection)url.openConnection();
        c.setRequestMethod("GET");
       
        assertEquals("text/xml; charset=utf-8", c.getContentType());
       
        Document doc = DOMUtils.readXml(c.getInputStream());
        addNamespace("b", "http://bare.http.binding.cxf.apache.org/");
        assertValid("//b:getDataResponse", doc);

        svr.stop();
    }
View Full Code Here

            if (serviceBean != null && getServiceClass() == null) {
                setServiceClass(serviceBean.getClass());
            }
           
            Endpoint ep = createEndpoint();
            server = new ServerImpl(getBus(),
                                    ep,
                                    getDestinationFactory(),
                                    getBindingFactory());
           
            if (invoker == null) {
View Full Code Here

                serviceFactory.create();
                updateClassResourceProviders();
            }
           
            Endpoint ep = createEndpoint();
            server = new ServerImpl(getBus(),
                                    ep,
                                    getDestinationFactory(),
                                    getBindingFactory());

            Invoker invoker = serviceFactory.getInvoker();
View Full Code Here

     */
    protected void doPublish(String addr) {
        checkPublishPermission();
        checkPublishable();
       
        ServerImpl serv = null;
       
        ClassLoaderHolder loader = null;
        try {
            if (bus != null) {
                ClassLoader newLoader = bus.getExtension(ClassLoader.class);
                if (newLoader != null) {
                    loader = ClassLoaderUtils.setThreadContextClassloader(newLoader);
                }
            }
            serv = getServer(addr);
            if (addr != null) {           
                EndpointInfo endpointInfo = serv.getEndpoint().getEndpointInfo();
                if (!endpointInfo.getAddress().contains(addr)) {
                    endpointInfo.setAddress(addr);
                }
                if (publishedEndpointUrl != null) {
                    // TODO is there a good place to put this key-string as a constant?
                    endpointInfo.setProperty("publishedEndpointUrl", publishedEndpointUrl);
                }

                if (null != properties) {
                    for (Entry<String, Object> entry : properties.entrySet()) {
                        endpointInfo.setProperty(entry.getKey(), entry.getValue());
                    }
                }

                this.address = endpointInfo.getAddress();
            }
            serv.start();
            publishable = false;
        } catch (Exception ex) {
            try {
                stop();
            } catch (Exception e) {
View Full Code Here

    public void testUpDownWithServlets() throws Exception {       
        setUpBus(true);
      
        Bus bus = (Bus)applicationContext.getBean("cxf");
        ServerRegistry sr = bus.getExtension(ServerRegistry.class);
        ServerImpl si = (ServerImpl) sr.getServers().get(0);
        JettyHTTPDestination jhd = (JettyHTTPDestination) si.getDestination();
        JettyHTTPServerEngine e = (JettyHTTPServerEngine) jhd.getEngine();
        org.eclipse.jetty.server.Server jettyServer = e.getServer();

        Handler[] contexts = jettyServer.getChildHandlersByClass(WebAppContext.class);
        WebAppContext servletContext = null;
View Full Code Here

   
    protected void doPublish(String addr) {
        checkPublishPermission();
       
        try {
            ServerImpl serv = getServer(addr);
            if (addr != null) {           
                EndpointInfo endpointInfo = serv.getEndpoint().getEndpointInfo();
                endpointInfo.setAddress(addr);
                if (publishedEndpointUrl != null) {
                    // TODO is there a good place to put this key-string as a constant?
                    endpointInfo.setProperty("publishedEndpointUrl", publishedEndpointUrl);
                }
                this.address = addr;
            }
            serv.start();
        } catch (WebServiceException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new WebServiceException(ex);
        }
View Full Code Here

TOP

Related Classes of org.apache.cxf.endpoint.ServerImpl

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.