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