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


Java Server.start方法代碼示例

本文整理匯總了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);
}
 
開發者ID:camelinaction,項目名稱:camelinaction2,代碼行數:38,代碼來源:RestOrderServer.java

示例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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:14,代碼來源:CxfPayLoadMessageXmlBindingRouterTest.java

示例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();
}
 
開發者ID:shawn-gogh,項目名稱:myjavacode,代碼行數:15,代碼來源:WebServiceTaskTest.java

示例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);
}
 
開發者ID:camelinaction,項目名稱:camelinaction2,代碼行數:56,代碼來源:RestOrderServer.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 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

示例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;
}
 
開發者ID:dana-i2cat,項目名稱:mqnaas,代碼行數:40,代碼來源:AbstractCXFSlicingCapability.java


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