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


Java Server類代碼示例

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


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

示例1: getJaxRestServer

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
@Bean
public Server getJaxRestServer(final GroupServiceRest groupServiceRest, final JvmServiceRest jvmServiceRest) {
    final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();

    factory.setAddress("/v2.0");

    final List<Object> serviceBeans = new ArrayList<>();
    serviceBeans.add(groupServiceRest);
    serviceBeans.add(jvmServiceRest);
    factory.setServiceBeans(serviceBeans);

    List<Object> providers = new ArrayList<>();
    providers.add(getJacksonJsonProvider());
    providers.add(getInternalServerErrorHandler());
    factory.setProviders(providers);
    return factory.create();
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:18,代碼來源:WebServiceConfig.java

示例2: jaxRsServer

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
@Bean
public Server jaxRsServer() {

  // List<Object> restServiceBeans = new
  // ArrayList<>(this.applicationContext.getBeansOfType(RestService.class).values());
  Collection<Object> restServices = findRestServices();
  if (restServices.isEmpty()) {
    LOG.info("No REST Services have been found. Rest Endpoint will not be enabled in CXF.");
    return null;
  }
  Collection<Object> providers = this.applicationContext.getBeansWithAnnotation(Provider.class).values();

  JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
  factory.setBus(springBus());
  factory.setAddress(URL_FOLDER_REST);
  // factory.set
  factory.setServiceBeans(new ArrayList<>(restServices));
  factory.setProviders(new ArrayList<>(providers));

  return factory.create();
}
 
開發者ID:oasp,項目名稱:oasp-tutorial-sources,代碼行數:22,代碼來源:ServiceConfig.java

示例3: initServerLookupMap

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
/**
 * Iterate over all available servers registered on the bus and build a map
 * consisting of (namespace, server) pairs for later lookup, so we can
 * redirect to the version-specific implementation according to the namespace
 * of the incoming message.
 */
private void initServerLookupMap(SoapMessage message) {
    Bus bus = message.getExchange().getBus();

    ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
    if (serverRegistry == null) {
        return;
    }

    List<Server> temp = serverRegistry.getServers();
    for (Server server : temp) {
        EndpointInfo info = server.getEndpoint().getEndpointInfo();
        String address = info.getAddress();

        // exclude the 'dummy' routing server
        if (CONFIG.getRouterEndpointPath().equals(address)) {
            continue;
        }

        String serverNamespace = info.getName().getNamespaceURI();
        actualServers.put(serverNamespace, server);
    }
}
 
開發者ID:RWTH-i5-IDSG,項目名稱:steve-plugsurfing,代碼行數:29,代碼來源:MediatorInInterceptor.java

示例4: createJaxrsServer

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
@Override
public JaxrsServer createJaxrsServer(Class<?> serviceInterface, Object serviceImplementation) {
    final String serviceName = namingStrategy.get().serviceName(serviceInterface);
    final Config serverConfig = configService.createServerConfig(serviceInterface, serviceName);
    final String baseAddress = serverConfig.value(BASE_ADDRESS_PROP).orElse(StringUtils.EMPTY);
    final String serverAddress = serverConfig.value(SERVER_ADDRESS_PROP).orElse(namingStrategy.get().serverAddress(serviceInterface));
    final String fullAddress = baseAddress + serverAddress;
    LOGGER.info("Starting {} JAX-RS server ({})...", serviceInterface.getSimpleName(), fullAddress);

    final DefaultJaxrsServiceDescriptor descriptor = new DefaultJaxrsServiceDescriptor(serviceInterface, serviceName);
    decorate(descriptor, serverConfig);
    final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setBus(BusFactory.getDefaultBus(true));
    sf.setServiceBean(serviceImplementation);

    sf.setAddress(fullAddress);
    sf.setFeatures(descriptor.getFeatures());
    sf.setProviders(descriptor.getProviders());
    final Server server = sf.create();
    LOGGER.info("Successfully started {} JAX-RS server ({}).", serviceInterface.getSimpleName(), serverAddress);
    return server::destroy;
}
 
開發者ID:Microbule,項目名稱:microbule,代碼行數:23,代碼來源:DefaultJaxrsServerFactory.java

示例5: serverEndPoint

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
@Bean
public Server serverEndPoint(final SpringBus bus)
{
	final JacksonJaxbJsonProvider jacksonJaxbJsonProvider = new JacksonJaxbJsonProvider();

	final JMSConfigFeature jmsConfigFeature = createJMSConfigFeature();

	final JAXRSServerFactoryBean svrFactory = new JAXRSServerFactoryBean();
	svrFactory.setBus(bus);
	svrFactory.setResourceClasses(AgentSync.class);

	svrFactory.getFeatures().add(jmsConfigFeature);
	svrFactory.getFeatures().add(loggingFeature);

	svrFactory.setProvider(jacksonJaxbJsonProvider);
	svrFactory.setAddress("/");
	svrFactory.setTransportId("http://cxf.apache.org/transports/jms");

	final Server server = svrFactory.create();
	return server;
}
 
開發者ID:metasfresh,項目名稱:metasfresh-procurement-webui,代碼行數:22,代碼來源:SyncConfiguration.java

示例6: jaxRsServer

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
@Bean
  @DependsOn("cxf")
  public Server jaxRsServer() {
      JAXRSServerFactoryBean serverFactory = RuntimeDelegate.getInstance().createEndpoint(jaxRsApiApplication(), JAXRSServerFactoryBean.class);
      
      //factory.setServiceBean(new DenialCategoryRest());
      
// get all the class annotated with @JaxrsService
      List<Object> beans = configUtil.findBeans( JaxrsService.class );

if (beans.size() > 0) {
	
	// add all the CXF service classes into the CXF stack
	serverFactory.setServiceBeans( beans );
	serverFactory.setAddress("/"+ serverFactory.getAddress());
	serverFactory.setBus(springBus);
	serverFactory.setStart(true);
	
	// set JSON as the response serializer
	JacksonJsonProvider provider = new JacksonJsonProvider();
	serverFactory.setProvider(provider);
       
}
      
return serverFactory.create();
  }
 
開發者ID:amoldavsky,項目名稱:restful-api-cxf-spring-java,代碼行數:27,代碼來源:CxfConfig.java

示例7: initialize

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
@Override
public void initialize(Server server, Bus bus) {
    server.getEndpoint().put("org.apache.cxf.binding.soap.addNamespaceContext", "true");
    server.getEndpoint().getBinding().getInInterceptors().add(new ConfigureDocLitWrapperInterceptor(true));
    if (server.getEndpoint().getBinding() instanceof SoapBinding) {
        server.getEndpoint().getBinding().getOutInterceptors().add(new SetSoapVersionInterceptor());
    }
    // Need to remove some interceptors that are incompatible
    // See above.
    removeInterceptor(server.getEndpoint().getInInterceptors(), 
                      HolderInInterceptor.class);
    removeInterceptor(server.getEndpoint().getOutInterceptors(), 
                      HolderOutInterceptor.class);
    removeInterceptor(server.getEndpoint().getBinding().getInInterceptors(), 
                      SoapHeaderInterceptor.class);
    resetPartTypes(server.getEndpoint().getBinding());

    LOG.info("Initialized CXF Server: {} in Payload mode with allow streaming: {}", server, allowStreaming);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:PayLoadDataFormatFeature.java

示例8: isServicePublished

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
/** 
 * This determines if the service has already been published on the CXF bus.
 * 
 * @return true if cxf server exists for this service.
 */
protected boolean isServicePublished(String serviceAddress) {
	
	ServerRegistry serverRegistry = getCXFServerRegistry();
	List<Server> servers = serverRegistry.getServers();
	
	for (Server server:servers){		
		String endpointAddress = server.getEndpoint().getEndpointInfo().getAddress();
		if (endpointAddress.contains(serviceAddress)){
			LOG.info("Service already published on CXF, not republishing: " + serviceAddress);
			return true;
		}
	}
	
	return false;
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:21,代碼來源:AbstractWebServiceExporter.java

示例9: 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

示例10: performJmsTransportTest

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
private void performJmsTransportTest(final String springBeanXml) throws IOException, URISyntaxException, Exception
{
	final BrokerService broker = setupJmsBroker();

	//
	// now we get the jax-rs endpoint from the xml config
	try (ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { springBeanXml }))
	{
		final JAXRSServerFactoryBean sfb = (JAXRSServerFactoryBean)ctx.getBean("jaxrs:server:jms");

		final Server server = sfb.getServer();
		assertThat(server, notNullValue()); // it's important that we can obtain the server bean
		assertThat(server.isStarted(), is(true)); // for all we care, we could also start the server, but we need to know if we have to or not

		runJmsClient();

		server.destroy();
		assertThat(server.isStarted(), is(false));
	}
	finally
	{
		broker.stop();
	}
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:25,代碼來源:JaxRsSpringEndpointTests.java

示例11: testServerWithJmsTransport

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
@Test
public void testServerWithJmsTransport() throws Exception
{
	final BrokerService jmsBroker = setupJmsBroker();
	try
	{
		final List<Class<?>> providers = Arrays.asList(TestService.class, TestService2.class);

		final Server server = createServer(providers);

		assertThat(server, notNullValue()); // it's important that we can obtain the server bean
		assertThat(server.isStarted(), is(true)); // for all we care, we could also start the server, but we need to know if we have to or not

		runJmsClient();

		server.destroy();
		assertThat(server.isStarted(), is(false));
	}
	finally
	{
		jmsBroker.stop();
	}
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:24,代碼來源:JaxRsProgramaticTests.java

示例12: invokeJaxWsMethod

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
/**
 * 使用客戶端代理調用
 * @param bean
 * @param intf
 * @param method
 * @param params
 * @return
 * @throws Exception
 */
protected Object invokeJaxWsMethod(Object bean, Class<?> intf, String method,Object... params) throws Exception {
	Assert.isTrue(Boolean.valueOf(intf.isInterface()), "The input class " + intf.getClass() + " is not an interface!");
	List<Class<?>> list = new ArrayList<Class<?>>();
	for (Object pobj : params) {
		list.add(pobj==null?null:pobj.getClass());
	}
	MethodEx me = BeanUtils.getCompatibleMethod(intf,method, list.toArray(new Class[list.size()]));
	Assert.notNull(me,"The Method "+method+" with "+params.length+" params was not found");
	//開始發布
	Server server = createLocalJaxWsService(intf, bean);
	//創建客戶端並運行
	try{
		String url = "local://" + intf.getName();
		Object client=jaxwsPlus.createProxy(url, intf);
		Object result=me.invoke(client, params);
		return result;
	}finally{
		server.destroy();
	}
}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:30,代碼來源:CXFTestBase.java

示例13: invokeRpcMethod

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
/**
 * 使用客戶端代理調用
 * @param bean
 * @param intf
 * @param method
 * @param params
 * @return
 * @throws Exception
 */
protected  Object[]  invokeRpcMethod(Object bean, Class<?> intf, String method,Object... params) throws Exception {
	Assert.isTrue(Boolean.valueOf(intf.isInterface()), "The input class " + intf.getClass() + " is not an interface!");
	List<Class<?>> list = new ArrayList<Class<?>>();
	for (Object pobj : params) {
		list.add(pobj==null?null:pobj.getClass());
	}
	//開始發布
	Server server = createLocalService(intf, bean);
	//創建客戶端並運行
	try{
		String url = "local://" + intf.getName();
		Client client=rpcPlus.createClient(url, intf);
		 Object[]  result=client.invoke(method, params);
		return result;
	}finally{
		server.destroy();
	}
}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:28,代碼來源:CXFTestBase.java

示例14: createLocalJaxWsService

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
/**
	 * 構造服務,注意要自己釋放
	 * @param intf
	 * @param bean
	 * @return
	 */
	private Server createLocalJaxWsService(Class<?> intf, Object bean) {
		String url = "local://" + intf.getName();
		ServiceDefinition ws = getFactory().processServiceDef(new ServiceDefinition(intf.getSimpleName(),intf,bean));
		if (ws == null)
			return null;
		JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(new CXFPlusServiceFactoryBean());
		sf.setAddress(url);
		sf.setServiceBean(ws.getServiceBean());
		sf.setServiceClass(ws.getServiceClass());
		if (printTrace()){
			sf.getInInterceptors().add(new LoggingInInterceptor());
			sf.getOutInterceptors().add(new LoggingOutInterceptor());
//			sf.getHandlers().add(TraceHandler.getSingleton());
		}
		Server server = sf.create();
		return server;
	}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:24,代碼來源:CXFTestBase.java

示例15: createLocalService

import org.apache.cxf.endpoint.Server; //導入依賴的package包/類
/**
 * 構造服務,注意要自己釋放
 * @param intf
 * @param bean
 * @return
 */
private Server createLocalService(Class<?> intf, Object bean) {
	String url = "local://" + intf.getName();
	ServiceDefinition ws = getFactory().processServiceDef(new ServiceDefinition(intf.getSimpleName(), intf, bean));
	if (ws == null)
		return null;
	ServerFactoryBean sf = new ServerFactoryBean(new CXFPlusServiceBean());
	sf.setAddress(url);
	sf.setServiceBean(ws.getServiceBean());
	sf.setServiceClass(ws.getServiceClass());
	if (printTrace()){
		sf.getInInterceptors().add(new LoggingInInterceptor());
		sf.getOutInterceptors().add(new LoggingOutInterceptor());
	}
	Server server = sf.create();
	return server;
}
 
開發者ID:GeeQuery,項目名稱:cxf-plus,代碼行數:23,代碼來源:CXFTestBase.java


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