當前位置: 首頁>>代碼示例>>Java>>正文


Java Server.stop方法代碼示例

本文整理匯總了Java中org.apache.cxf.endpoint.Server.stop方法的典型用法代碼示例。如果您正苦於以下問題:Java Server.stop方法的具體用法?Java Server.stop怎麽用?Java Server.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.cxf.endpoint.Server的用法示例。


在下文中一共展示了Server.stop方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    // create dummy backend
    DummyOrderService dummy = new DummyOrderService();
    dummy.setupDummyOrders();

    // create CXF REST service and inject the dummy backend
    RestOrderService rest = new RestOrderService();
    rest.setOrderService(dummy);

    // setup Apache CXF REST server on port 9000
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(RestOrderService.class);
    sf.setResourceProvider(RestOrderService.class, new SingletonResourceProvider(rest));
    sf.setAddress("http://localhost:9000/");

    // create and start the CXF server (non blocking)
    Server server = sf.create();
    server.start();

    // keep the JVM running
    Console console = System.console();
    System.out.println("Server started on http://localhost:9000/");
    System.out.println("");

    // If you run the main class from IDEA/Eclipse then you may not have a console, which is null)
    if (console != null) {
        System.out.println("  Press ENTER to stop server");
        console.readLine();
    } else {
        System.out.println("  Stopping after 5 minutes or press ctrl + C to stop");
        Thread.sleep(5 * 60 * 1000);
    }

    // stop CXF server
    server.stop();
    System.exit(0);
}
 
開發者ID:camelinaction,項目名稱:camelinaction2,代碼行數:38,代碼來源:RestOrderServer.java

示例2: testDecoupledEndpoint

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
@Test
public void testDecoupledEndpoint() throws Exception {

    JaxWsServerFactoryBean serverFactory = new JaxWsServerFactoryBean();
    serverFactory.setAddress("zmq:(tcp://*:" + ZMQ_TEST_PORT + "?socketOperation=bind&socketType=pull)");
    serverFactory.setServiceClass(HelloWorldImpl.class);
    Server server = serverFactory.create();

    JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
    clientFactory.setServiceClass(HelloWorldPortType.class);
    clientFactory.setAddress("zmq:(tcp://localhost:" + ZMQ_TEST_PORT + "?socketOperation=connect&socketType=push)");
    clientFactory.getFeatures().add(new WSAddressingFeature());

    HelloWorldPortType client = (HelloWorldPortType) clientFactory.create();

    ClientProxy.getClient(client).getEndpoint()
                                 .getEndpointInfo()
                                 .setProperty("org.apache.cxf.ws.addressing.replyto",
                                              "zmq:(tcp://127.0.0.1:5555?socketOperation=connect&socketType=push)");

    String reply = client.sayHello("Claude");

    server.stop();

    assertEquals("Hello Claude", reply);
}
 
開發者ID:claudemamo,項目名稱:cxf-rt-transports-zeromq,代碼行數:27,代碼來源:ZMQConduitTest.java

示例3: testConfigurationFromAPI

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
@Test
public void testConfigurationFromAPI() throws Exception {

    JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean();
    bean.setAddress("zmq:(tcp://*:" + ZMQ_TEST_PORT + "?socketOperation=bind&socketType=rep)");
    bean.setServiceClass(HelloWorldImpl.class);
    Server server = bean.create();

    ZMQ.Socket zmqSocket = zmqContext.socket(ZMQ.REQ);
    zmqSocket.connect("tcp://localhost:" + ZMQ_TEST_PORT);
    zmqSocket.send(FileUtils.readFileToString(new File(getClass().getResource("/samples/soap-request.xml").toURI())).getBytes(), 0);
    byte[] reply = zmqSocket.recv(0);
    zmqSocket.close();

    server.stop();

    XMLAssert.assertXMLEqual(FileUtils.readFileToString(new File(getClass().getResource("/samples/soap-reply.xml").toURI())), new String(reply));
}
 
開發者ID:claudemamo,項目名稱:cxf-rt-transports-zeromq,代碼行數:19,代碼來源:ZMQDestinationTest.java

示例4: testConfigurationFromWSDL

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
@Test
public void testConfigurationFromWSDL() throws Exception {
    JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean();
    bean.setWsdlLocation("/wsdl/zmq_test.wsdl");
    bean.setServiceClass(HelloWorldImpl.class);
    Server server = bean.create();

    ZMQ.Socket zmqSocket = zmqContext.socket(ZMQ.REQ);
    zmqSocket.connect("tcp://localhost:" + ZMQ_TEST_PORT);
    zmqSocket.send(FileUtils.readFileToString(new File(getClass().getResource("/samples/soap-request.xml").toURI())).getBytes(), 0);
    byte[] reply = zmqSocket.recv(0);
    zmqSocket.close();

    server.stop();

    XMLAssert.assertXMLEqual(FileUtils.readFileToString(new File(getClass().getResource("/samples/soap-reply.xml").toURI())), new String(reply));
}
 
開發者ID:claudemamo,項目名稱:cxf-rt-transports-zeromq,代碼行數:18,代碼來源:ZMQDestinationTest.java

示例5: main

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    // create dummy backend
    DummyOrderService dummy = new DummyOrderService();
    dummy.setupDummyOrders();

    // create a Camel route that routes the REST services
    OrderRoute route = new OrderRoute();
    route.setOrderService(dummy);

    // create CamelContext and add the route
    CamelContext camel = new DefaultCamelContext();
    camel.addRoutes(route);

    // create a ProducerTemplate that the CXF REST service will use to integrate with Camel
    ProducerTemplate producer = camel.createProducerTemplate();

    // create CXF REST service and inject the Camel ProducerTemplate
    // which we use to call the Camel route
    RestOrderService rest = new RestOrderService();
    rest.setProducerTemplate(producer);

    // setup Apache CXF REST server on port 9000
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(RestOrderService.class);
    sf.setResourceProvider(RestOrderService.class, new SingletonResourceProvider(rest));
    // to use jackson for json
    sf.setProvider(JacksonJsonProvider.class);
    sf.setAddress("http://localhost:9000/");

    // create the CXF server
    Server server = sf.create();

    // start Camel and CXF (non blocking)
    camel.start();
    server.start();

    // keep the JVM running
    Console console = System.console();
    System.out.println("Server started on http://localhost:9000/");
    System.out.println("");

    // If you run the main class from IDEA/Eclipse then you may not have a console, which is null)
    if (console != null) {
        System.out.println("  Press ENTER to stop server");
        console.readLine();
    } else {
        System.out.println("  Stopping after 5 minutes or press ctrl + C to stop");
        Thread.sleep(5 * 60 * 1000);
    }

    // stop Camel and CXF server
    camel.stop();
    server.stop();
    System.exit(0);
}
 
開發者ID:camelinaction,項目名稱:camelinaction2,代碼行數:56,代碼來源:RestOrderServer.java

示例6: main

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    // create dummy backend
    DummyOrderService dummy = new DummyOrderService();
    dummy.setupDummyOrders();

    // create CXF REST service and inject the dummy backend
    RestOrderService rest = new RestOrderService();
    rest.setOrderService(dummy);

    // setup Apache CXF REST server on port 9000
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(RestOrderService.class);
    sf.setResourceProvider(RestOrderService.class, new SingletonResourceProvider(rest));
    // to use jackson for json
    sf.setProvider(JacksonJsonProvider.class);
    sf.setAddress("http://localhost:9000/");

    // create and start the CXF server (non blocking)
    Server server = sf.create();
    server.start();

    // keep the JVM running
    Console console = System.console();
    System.out.println("Server started on http://localhost:9000/");
    System.out.println("");

    // If you run the main class from IDEA/Eclipse then you may not have a console, which is null)
    if (console != null) {
        System.out.println("  Press ENTER to stop server");
        console.readLine();
    } else {
        System.out.println("  Stopping after 5 minutes or press ctrl + C to stop");
        Thread.sleep(5 * 60 * 1000);
    }

    // stop CXF server
    server.stop();
    System.exit(0);
}
 
開發者ID:camelinaction,項目名稱:camelinaction2,代碼行數:40,代碼來源:RestOrderServer.java

示例7: generateJaxWsWSDL

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
/**
 * 將指定的接口發布為服務,然後生成WSDL文檔(JaxWs模式)
 * @param intf
 * @return
 * @throws WSDLException
 */
protected Document generateJaxWsWSDL(Class<?> intf) throws WSDLException{
	Assert.isTrue(Boolean.valueOf(intf.isInterface()), "The input class " + intf.getClass() + " is not an interface!");
	Server server = createLocalJaxWsService(intf, new Object());
	try{
		return super.getWSDLDocument(server);
	}finally{
		server.stop();
		server.destroy();
	}
}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:17,代碼來源:CXFTestBase.java

示例8: generateRpcWSDL

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
/**
 * 將指定的接口發布為服務,然後生成WSDL文檔(RPC模式)
 * @param intf
 * @return
 * @throws WSDLException
 */
protected Document generateRpcWSDL(Class<?> intf) throws WSDLException{
	Assert.isTrue(Boolean.valueOf(intf.isInterface()), "The input class " + intf.getClass() + " is not an interface!");
	Server server = createLocalService(intf,new Object() );
	try{
		return super.getWSDLDocument(server);
	}finally{
		server.stop();
		server.destroy();
	}
}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:17,代碼來源:CXFTestBase.java

示例9: createSlice

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
@Override
// TODO current implementation does nothing with the slice. In the future, it has to create the new resource based on the slice information.
public IResource createSlice(IResource slice) throws SlicingException {
	log.info("Virtual resource creation request received in resource " + resource.getId());

	if (slice == null)
		throw new NullPointerException("Slice resource to create can not be null.");

	if (!(slice instanceof SliceResource))
		throw new IllegalArgumentException("Resource must be of type " + SliceResource.class.getName() + ", but is of type + " + slice.getClass()
				.getName());

	IRootResource createdResource = null;

	Endpoint endpoint = getEndpoint(slice);

	Server proxy = createServer(endpoint);
	log.trace("Publishing virtual resource proxy endpoint in url " + endpoint);
	proxy.start();

	try {
		List<Endpoint> endpoints = new ArrayList<Endpoint>();
		endpoints.add(endpoint);

		createdResource = new RootResource(RootResourceDescriptor.create(resource.getDescriptor().getSpecification().clone(), endpoints));
		createdResource.getDescriptor().getSpecification().setModel("virtual");
	} catch (Exception e) {
		log.error("Error creating virtual resource.", e);
		proxy.stop();
		throw new SlicingException(e);
	}

	virtualResources.add(createdResource);
	proxiesEndpoints.put(createdResource, proxy);

	log.info("Virtual resource created with id " + createdResource.getId());

	return createdResource;
}
 
開發者ID:dana-i2cat,項目名稱:mqnaas,代碼行數:40,代碼來源:AbstractCXFSlicingCapability.java

示例10: testReplyTo

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
@Test
public void testReplyTo() throws Exception {

    JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean();
    bean.setAddress("zmq:(tcp://*:" + ZMQ_TEST_PORT + "?socketOperation=bind&socketType=pull)");
    bean.setServiceClass(HelloWorldImpl.class);
    Server server = bean.create();

    ZMQ.Socket zmqSocket = zmqContext.socket(ZMQ.PUSH);
    zmqSocket.connect("tcp://localhost:" + ZMQ_TEST_PORT);
    zmqSocket.send(FileUtils.readFileToString(new File(getClass().getResource("/samples/soap-wa-request.xml").toURI())).getBytes(), 0);
    zmqSocket.close();

    ZMQ.Socket receiverSocket = zmqContext.socket(ZMQ.PULL);
    receiverSocket.bind("tcp://*:9001");
    byte[] reply = receiverSocket.recv(0);
    receiverSocket.close();

    server.stop();

    Diff myDiff = new Diff(FileUtils.readFileToString(new File(getClass().getResource("/samples/soap-wa-reply.xml").toURI())), new String(reply));
    DetailedDiff myDifferenceListener = new DetailedDiff(myDiff);
    List<Difference> diffs = myDifferenceListener.getAllDifferences();

    assertEquals(1, diffs.size());
    assertEquals("/Envelope[1]/Header[1]/MessageID[1]/text()[1]", diffs.get(0).getControlNodeDetail().getXpathLocation());
}
 
開發者ID:claudemamo,項目名稱:cxf-rt-transports-zeromq,代碼行數:28,代碼來源:ZMQDestinationTest.java

示例11: undeploy

import org.apache.cxf.endpoint.Server; //導入方法依賴的package包/類
/**
 * Undeploy the service whose name is serviceName
 *
 * @param serviceName name of the service
 */
public void undeploy(String serviceName) {
    Server serviceServer = serverList.get(serviceName);
    serviceServer.stop();
    serverList.remove(serviceName);
    logger.debug("The service " + serviceName + " has been undeployed");
}
 
開發者ID:mnip91,項目名稱:proactive-component-monitoring,代碼行數:12,代碼來源:ServiceDeployer.java


注:本文中的org.apache.cxf.endpoint.Server.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。