本文整理汇总了Java中org.apache.cxf.endpoint.Server.start方法的典型用法代码示例。如果您正苦于以下问题:Java Server.start方法的具体用法?Java Server.start怎么用?Java Server.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.endpoint.Server
的用法示例。
在下文中一共展示了Server.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: startService
import org.apache.cxf.endpoint.Server; //导入方法依赖的package包/类
@BeforeClass
public static void startService() {
//start a service
ServerFactoryBean svrBean = new ServerFactoryBean();
svrBean.setAddress(SERVICE_ADDRESS);
svrBean.setServiceClass(HelloService.class);
svrBean.setServiceBean(new HelloServiceImpl());
svrBean.setBindingId(getBindingId());
Server server = svrBean.create();
server.start();
}
示例3: main
import org.apache.cxf.endpoint.Server; //导入方法依赖的package包/类
/**
* 独立启动WebService服务
*/
public static void main(String[] args) {
Counter counter = new CounterImpl();
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(Counter.class);
svrFactory.setAddress("http://localhost:12345/counter");
svrFactory.setServiceBean(counter);
svrFactory.getInInterceptors().add(new LoggingInInterceptor());
svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
Server server = svrFactory.create();
server.start();
}
示例4: 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);
}
示例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 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);
}
示例6: 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;
}