本文整理汇总了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);
}
示例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);
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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());
}
示例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");
}