CXFConfig.java
3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package com.bsth;
import com.bsth.server_rs.AuthorizeInterceptor_IN;
import com.bsth.server_rs.base_info.car.CarRestService;
import com.bsth.server_rs.base_info.carpark.CarparkRestService;
import com.bsth.server_rs.base_info.line.LineRestService;
import com.bsth.server_rs.base_info.person.PersonRestService;
import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
import com.bsth.server_rs.base_info.section.LD_SectionRestService;
import com.bsth.server_rs.base_info.station.StationRestService;
import com.bsth.server_rs.bigdata.BigdataService;
import com.bsth.server_rs.bigdata.BigscreenService;
import com.bsth.server_rs.departure.DepartureRestService;
import com.bsth.server_rs.destroy.DestroyDetailRestService;
import com.bsth.server_rs.exception.AesExceptionMapper;
import com.bsth.server_rs.gps.GpsRestService;
import com.bsth.server_rs.logs.RealLogRestService;
import com.bsth.server_rs.rate.RateService;
import com.bsth.server_rs.waybill.WaybillRestService;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import java.util.Arrays;
/**
* Created by panzhao on 2017/3/9.
*/
@Configuration
public class CXFConfig {
@Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
return new SpringBus();
}
@Autowired
StationRestService stationRestService;
@Autowired
LD_SectionRestService ldSectionRestService;
@Autowired
RealLogRestService realLogRestService;
@Autowired
GpsRestService gpsRestService;
@Autowired
WaybillRestService waybillRestService;
@Autowired
LD_RoadSpeedRestService ld_roadSpeedRestService;
@Autowired
BigdataService bigdataService;
@Autowired
BigscreenService bigscreenService;
@Autowired
RateService rateService;
@Autowired
private DestroyDetailRestService destroyDetailRestService;
@Autowired
private CarparkRestService carparkRestService;
@Autowired
private DepartureRestService departureRestService;
@Bean
public Server rsServer() {
JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
endpoint.setBus(springBus());
endpoint.setAddress("/rest");
endpoint.setServiceBeans(Arrays.<Object>asList(
new LineRestService(),
new CarRestService(),
new PersonRestService(),
gpsRestService,
waybillRestService,
stationRestService,
ldSectionRestService,
realLogRestService,
ld_roadSpeedRestService,
bigdataService,
bigscreenService,
rateService,
destroyDetailRestService,
carparkRestService,
departureRestService));
endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
//endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
return endpoint.create();
}
@Bean
public ServletRegistrationBean servletRegistrationBean() {
ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
bean.setLoadOnStartup(0);
bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
return bean;
}
}