Package org.apache.cxf.endpoint

Examples of org.apache.cxf.endpoint.Server


    @Before
    public void setUp() throws Exception {
        super.setUp();
        Server s = createService(JaxbService.class);
        service = s.getEndpoint().getService();
        databinding = (AegisDatabinding) service.getDataBinding();

        tm = databinding.getAegisContext().getTypeMapping();
    }
View Full Code Here


        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
        sf.setAddress("http://localhost:" + PORT + "/Echo");
        sf.setDataBinding(new AegisDatabinding());
        sf.setServiceBean(new Echo());
        sf.getInInterceptors().add(new URIMappingInterceptor());
        Server server = sf.create();
        // turn off nanny in URIMappingInterceptor
        server.getEndpoint()
            .getService().put(AbstractInDatabindingInterceptor.NO_VALIDATE_PARTS, Boolean.TRUE);
       
        ServerFactoryBean sf2 = new ServerFactoryBean();
        sf2.setAddress("http://localhost:" + PORT + "/SimpleEcho");
        sf2.setDataBinding(new AegisDatabinding());
        sf2.setServiceBean(new Echo());
        sf2.getInInterceptors().add(new URIMappingInterceptor());
        server = sf2.create();
        // turn off nanny in URIMappingInterceptor
        server.getEndpoint()
            .getService().put(AbstractInDatabindingInterceptor.NO_VALIDATE_PARTS, Boolean.TRUE);
    }
View Full Code Here

        f.setTransportIds(tp);
        f.setBus(bus);
        f.register();
       
       
        Server s = factory.create();

        try {
            ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus,
                                                                s.getEndpoint().getService()
                                                                    .getServiceInfos());
            Definition def = builder.build();
            WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class)
                .getWSDLFactory().newWSDLWriter();
            def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
            Element wsdl = wsdlWriter.getDocument(def).getDocumentElement();
           
            Map<String, String> ns = new HashMap<String, String>();
            ns.put("wsdl", WSDLConstants.NS_WSDL11);
            ns.put("wsu",
                   "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
            ns.put("wsp", Constants.URI_POLICY_13_NS);
            XPathUtils xpu = new XPathUtils(ns);
            //org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
            check(xpu, wsdl, "/wsdl:definitions/wsdl:service/wsdl:port", "TestImplPortPortPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/", "TestInterfacePortTypePolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/", "echoIntPortTypeOpPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:input",
                  "echoIntPortTypeOpInputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:portType/wsdl:operation/wsdl:output",
                  "echoIntPortTypeOpOutputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/", "TestImplServiceSoapBindingBindingPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/", "echoIntBindingOpPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:input",
                  "echoIntBindingOpInputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:binding/wsdl:operation/wsdl:output",
                  "echoIntBindingOpOutputPolicy");
            check(xpu, wsdl, "/wsdl:definitions/wsdl:service/", "TestImplServiceServicePolicy");
           
            assertEquals(1,
                         xpu.getValueList("/wsdl:definitions/wsdl:binding/wsdl:operation/"
                                              + "wsp:PolicyReference[@URI='#echoIntBindingOpPolicy']", wsdl)
                             .getLength());
           
            EndpointPolicy policy = bus.getExtension(PolicyEngine.class)
                .getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null);
            assertNotNull(policy);
            assertEquals(1, policy.getChosenAlternative().size());
        } finally {
            bus.shutdown(true);
        }
View Full Code Here

        f.setTransportIds(tp);
        f.setBus(bus);
        f.register();
       
       
        Server s = factory.create();

        try {
            ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus,
                                                                s.getEndpoint().getService()
                                                                    .getServiceInfos());
            Definition def = builder.build();
            WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class)
                .getWSDLFactory().newWSDLWriter();
            def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
View Full Code Here

    // } catch (ClassNotFoundException e) {
    // // TODO Auto-generated catch block
    // e.printStackTrace();
    // }

    Server res = srvFactory.create();

    while (!res.isStarted()) {
        try {
      logger.info("Server {} not started, waiting..",
        srvFactory.getAddress());
      Thread.sleep(1000);
        } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
        }
    }

    logger.info("Server {} started!", res.getEndpoint()
      .getEndpointInfo().getAddress());

    webservices.put(srvFactory.getAddress(), res);

    result.put(iface, res.getEndpoint().getEndpointInfo()
      .getAddress());

      } finally {
    // reset the context classloader to the original one.
    // Thread.currentThread().setContextClassLoader(loader);
View Full Code Here

  logger.info("destroying endpoints..");

  for (Map.Entry<String, Server> element : webservices.entrySet()) {
      String wsUrl = element.getKey();
      Server entrypoint = element.getValue();
      entrypoint.stop();
      logger.info("endpoint {} destroyed.", wsUrl);
      webservices.remove(element.getKey());
  }

    }
View Full Code Here

        PersonServiceImpl personServiceImpl = new PersonServiceImpl();
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        factory.setAddress("http://localhost:8282/person");
        factory.setServiceClass(PersonService.class);
        factory.setServiceBean(personServiceImpl);
        Server server = factory.create();
        server.start();
    }
View Full Code Here

        JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
        factory.setAddress("http://localhost:8282/person");
        factory.setResourceClasses(PersonServiceImpl.class);
        factory.setResourceProvider(new SingletonResourceProvider(new PersonServiceImpl()));
        factory.setProvider(new JAXBElementProvider());
        Server server = factory.create();
        server.start();
    }
View Full Code Here

    public void testBasicInvocation() throws Exception {

        Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());

        Server server1 = null;
        Server server2 = null;
        ServiceTracker tracker = null;
        try {
            server1 = startServer(ADDRESS1,
                                  GreeterService.class, new GreeterServiceImpl());
           
            server2 = startServer(ADDRESS2,
                                  GreeterService.class, new GreeterServiceImpl());
            tracker = new ServiceTracker(bundleContext,
                                         GreeterService.class.getName(), null) {
                @Override
                public Object addingService(final ServiceReference reference) {
                    Object result = super.addingService(reference);

                    FutureTask<Map<GreetingPhrase, String>> future =
                        new FutureTask<Map<GreetingPhrase, String>>(new Callable<Map<GreetingPhrase, String>>() {
                          public Map<GreetingPhrase, String> call() {
                            return useService(reference);
                        }});
                    future.run();
                    synchronized (mutex1) {
                        synchronized (mutex2) {
                            if (task1 == null) {
                                task1 = future;
                                mutex1.notify();
                            } else if (task2 == null) {
                                task2 = future;
                                mutex2.notify();
                            }
                        }
                    }
                    return result;
                }
            };
            tracker.open();
            // sleep for a bit
            Thread.sleep(2000);
           
            installDswIfNeeded();

            verifyGreeterResponse(task1, mutex1);
            verifyGreeterResponse(task2, mutex2);
        } finally {
            if (tracker != null) {
                tracker.close();
            }
           
            if (server1 != null) {
                server1.getDestination().shutdown();
                server1.stop();
            }

            if (server2 != null) {
                server2.getDestination().shutdown();
                server2.stop();
            }
           
        }
    }
View Full Code Here

        ServerFactoryBean factory = new ServerFactoryBean();
        factory.setServiceClass(type);
        factory.setAddress(address);
        factory.getServiceFactory().setDataBinding(new AegisDatabinding());
        factory.setServiceBean(impl);
        Server server = factory.create();
        server.start();
        return server;
    }
View Full Code Here

TOP

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

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.