Commit 4b4f29e8b3eeca6dfbd1d6d6408b46045f0438a9

Authored by 娄高锋
1 parent 57dd55fa

浦交大屏数据接口

src/main/java/com/bsth/CXFConfig.java
1 -package com.bsth;  
2 -  
3 -  
4 -import com.bsth.server_rs.AuthorizeInterceptor_IN;  
5 -import com.bsth.server_rs.base_info.car.CarRestService;  
6 -import com.bsth.server_rs.base_info.line.LineRestService;  
7 -import com.bsth.server_rs.base_info.person.PersonRestService;  
8 -import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;  
9 -import com.bsth.server_rs.base_info.section.LD_SectionRestService;  
10 -import com.bsth.server_rs.base_info.station.StationRestService;  
11 -import com.bsth.server_rs.bigdata.BigdataService;  
12 -import com.bsth.server_rs.directive.DirectiveRestService;  
13 -import com.bsth.server_rs.electric.ElectricService;  
14 -import com.bsth.server_rs.exception.AesExceptionMapper;  
15 -import com.bsth.server_rs.gps.GpsRestService;  
16 -import com.bsth.server_rs.logs.RealLogRestService;  
17 -import com.bsth.server_rs.rate.RateService;  
18 -import com.bsth.server_rs.schedule.plan.SchedulePlanService;  
19 -import com.bsth.server_rs.schedule.real.ScheduleRealService;  
20 -import com.bsth.server_rs.schedule.real.StaffViewRealService;  
21 -import com.bsth.server_rs.waybill.WaybillRestService;  
22 -import com.bsth.server_ws.attendance.AttendanceServiceSoap;  
23 -import com.bsth.server_ws.electric_oil.OilServiceSoap;  
24 -import com.bsth.server_ws.park_station.CompanyServiceSoap;  
25 -import com.bsth.server_ws.waybill.LD_ServiceSoap;  
26 -import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;  
27 -import org.apache.cxf.Bus;  
28 -import org.apache.cxf.bus.spring.SpringBus;  
29 -import org.apache.cxf.endpoint.Server;  
30 -import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;  
31 -import org.apache.cxf.jaxws.EndpointImpl;  
32 -import org.apache.cxf.transport.servlet.CXFServlet;  
33 -import org.springframework.beans.factory.annotation.Autowired;  
34 -import org.springframework.boot.web.servlet.ServletRegistrationBean;  
35 -import org.springframework.context.annotation.Bean;  
36 -import org.springframework.context.annotation.Configuration;  
37 -import org.springframework.core.Ordered;  
38 -  
39 -import javax.xml.ws.Endpoint;  
40 -import java.util.Arrays;  
41 -  
42 -/**  
43 - * Created by panzhao on 2017/3/9.  
44 - */  
45 -@Configuration  
46 -public class CXFConfig {  
47 -  
48 - @Bean(name = Bus.DEFAULT_BUS_ID)  
49 - public SpringBus springBus() {  
50 - return new SpringBus();  
51 - }  
52 -  
53 - @Autowired  
54 - CompanyServiceSoap companyServiceSoap;  
55 - @Autowired  
56 - LD_ServiceSoap ld_serviceSoap;  
57 - @Autowired  
58 - AttendanceServiceSoap attendanceServiceSoap;  
59 - @Autowired  
60 - OilServiceSoap oilServiceSoap;  
61 -  
62 - @Bean  
63 - public Endpoint companyEndpoint() {  
64 - EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);  
65 - endpoint.publish("/CompanyService");  
66 - //endpoint.getInInterceptors().add(new AuthInterceptor());  
67 - return endpoint;  
68 - }  
69 -  
70 - @Bean  
71 - public Endpoint ldServiceEndpoint() {  
72 - EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);  
73 - endpoint.publish("/LD_Service");  
74 - //endpoint.getInInterceptors().add(new AuthInterceptor());  
75 - return endpoint;  
76 - }  
77 -  
78 - @Bean  
79 - public Endpoint attendanceServiceEndpoint() {  
80 - EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);  
81 - endpoint.publish("/attendanceService");  
82 - //endpoint.getInInterceptors().add(new AuthInterceptor());  
83 - return endpoint;  
84 - }  
85 -  
86 - @Bean  
87 - public Endpoint electricServiceEndpoint() {  
88 - EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);  
89 - endpoint.publish("/oilServiceSoap");  
90 - //endpoint.getInInterceptors().add(new AuthInterceptor());  
91 - return endpoint;  
92 - }  
93 -  
94 - @Autowired  
95 - ScheduleRealService scheduleRealService;  
96 - @Autowired  
97 - StationRestService stationRestService;  
98 - @Autowired  
99 - LD_SectionRestService ldSectionRestService;  
100 - @Autowired  
101 - SchedulePlanService schedulePlanService;  
102 - @Autowired  
103 - RealLogRestService realLogRestService;  
104 - @Autowired  
105 - GpsRestService gpsRestService;  
106 - @Autowired  
107 - WaybillRestService waybillRestService;  
108 - @Autowired  
109 - DirectiveRestService directiveRestService;  
110 - @Autowired  
111 - LD_RoadSpeedRestService ld_roadSpeedRestService;  
112 - @Autowired  
113 - ElectricService electricService;  
114 - @Autowired  
115 - BigdataService bigdataService;  
116 - @Autowired  
117 - StaffViewRealService staffViewRealService;  
118 - @Autowired  
119 - RateService rateService;  
120 -  
121 - @Bean  
122 - public Server rsServer() {  
123 - JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();  
124 - endpoint.setBus(springBus());  
125 - endpoint.setAddress("/rest");  
126 - endpoint.setServiceBeans(Arrays.<Object>asList(  
127 - new LineRestService(),  
128 - new CarRestService(),  
129 - new PersonRestService(),  
130 - gpsRestService,  
131 - waybillRestService,  
132 - scheduleRealService,  
133 - stationRestService,  
134 - ldSectionRestService,  
135 - schedulePlanService,  
136 - realLogRestService,  
137 - directiveRestService,  
138 - ld_roadSpeedRestService,  
139 - electricService,  
140 - staffViewRealService,  
141 - bigdataService,  
142 - rateService));  
143 - endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));  
144 - //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));  
145 - endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());  
146 - return endpoint.create();  
147 - }  
148 -  
149 - @Bean  
150 - public ServletRegistrationBean servletRegistrationBean() {  
151 - ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");  
152 - bean.setLoadOnStartup(0);  
153 - bean.setOrder(Ordered.HIGHEST_PRECEDENCE);  
154 - return bean;  
155 - }  
156 -} 1 +package com.bsth;
  2 +
  3 +
  4 +import com.bsth.server_rs.AuthorizeInterceptor_IN;
  5 +import com.bsth.server_rs.base_info.car.CarRestService;
  6 +import com.bsth.server_rs.base_info.line.LineRestService;
  7 +import com.bsth.server_rs.base_info.person.PersonRestService;
  8 +import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService;
  9 +import com.bsth.server_rs.base_info.section.LD_SectionRestService;
  10 +import com.bsth.server_rs.base_info.station.StationRestService;
  11 +import com.bsth.server_rs.bigdata.BigdataService;
  12 +import com.bsth.server_rs.bigdata.BigscreenService;
  13 +import com.bsth.server_rs.directive.DirectiveRestService;
  14 +import com.bsth.server_rs.electric.ElectricService;
  15 +import com.bsth.server_rs.exception.AesExceptionMapper;
  16 +import com.bsth.server_rs.gps.GpsRestService;
  17 +import com.bsth.server_rs.logs.RealLogRestService;
  18 +import com.bsth.server_rs.rate.RateService;
  19 +import com.bsth.server_rs.schedule.plan.SchedulePlanService;
  20 +import com.bsth.server_rs.schedule.real.ScheduleRealService;
  21 +import com.bsth.server_rs.schedule.real.StaffViewRealService;
  22 +import com.bsth.server_rs.waybill.WaybillRestService;
  23 +import com.bsth.server_ws.attendance.AttendanceServiceSoap;
  24 +import com.bsth.server_ws.electric_oil.OilServiceSoap;
  25 +import com.bsth.server_ws.park_station.CompanyServiceSoap;
  26 +import com.bsth.server_ws.waybill.LD_ServiceSoap;
  27 +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
  28 +import org.apache.cxf.Bus;
  29 +import org.apache.cxf.bus.spring.SpringBus;
  30 +import org.apache.cxf.endpoint.Server;
  31 +import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
  32 +import org.apache.cxf.jaxws.EndpointImpl;
  33 +import org.apache.cxf.transport.servlet.CXFServlet;
  34 +import org.springframework.beans.factory.annotation.Autowired;
  35 +import org.springframework.boot.web.servlet.ServletRegistrationBean;
  36 +import org.springframework.context.annotation.Bean;
  37 +import org.springframework.context.annotation.Configuration;
  38 +import org.springframework.core.Ordered;
  39 +
  40 +import javax.xml.ws.Endpoint;
  41 +import java.util.Arrays;
  42 +
  43 +/**
  44 + * Created by panzhao on 2017/3/9.
  45 + */
  46 +@Configuration
  47 +public class CXFConfig {
  48 +
  49 + @Bean(name = Bus.DEFAULT_BUS_ID)
  50 + public SpringBus springBus() {
  51 + return new SpringBus();
  52 + }
  53 +
  54 + @Autowired
  55 + CompanyServiceSoap companyServiceSoap;
  56 + @Autowired
  57 + LD_ServiceSoap ld_serviceSoap;
  58 + @Autowired
  59 + AttendanceServiceSoap attendanceServiceSoap;
  60 + @Autowired
  61 + OilServiceSoap oilServiceSoap;
  62 +
  63 + @Bean
  64 + public Endpoint companyEndpoint() {
  65 + EndpointImpl endpoint = new EndpointImpl(springBus(), companyServiceSoap);
  66 + endpoint.publish("/CompanyService");
  67 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  68 + return endpoint;
  69 + }
  70 +
  71 + @Bean
  72 + public Endpoint ldServiceEndpoint() {
  73 + EndpointImpl endpoint = new EndpointImpl(springBus(), ld_serviceSoap);
  74 + endpoint.publish("/LD_Service");
  75 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  76 + return endpoint;
  77 + }
  78 +
  79 + @Bean
  80 + public Endpoint attendanceServiceEndpoint() {
  81 + EndpointImpl endpoint = new EndpointImpl(springBus(), attendanceServiceSoap);
  82 + endpoint.publish("/attendanceService");
  83 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  84 + return endpoint;
  85 + }
  86 +
  87 + @Bean
  88 + public Endpoint electricServiceEndpoint() {
  89 + EndpointImpl endpoint = new EndpointImpl(springBus(), oilServiceSoap);
  90 + endpoint.publish("/oilServiceSoap");
  91 + //endpoint.getInInterceptors().add(new AuthInterceptor());
  92 + return endpoint;
  93 + }
  94 +
  95 + @Autowired
  96 + ScheduleRealService scheduleRealService;
  97 + @Autowired
  98 + StationRestService stationRestService;
  99 + @Autowired
  100 + LD_SectionRestService ldSectionRestService;
  101 + @Autowired
  102 + SchedulePlanService schedulePlanService;
  103 + @Autowired
  104 + RealLogRestService realLogRestService;
  105 + @Autowired
  106 + GpsRestService gpsRestService;
  107 + @Autowired
  108 + WaybillRestService waybillRestService;
  109 + @Autowired
  110 + DirectiveRestService directiveRestService;
  111 + @Autowired
  112 + LD_RoadSpeedRestService ld_roadSpeedRestService;
  113 + @Autowired
  114 + ElectricService electricService;
  115 + @Autowired
  116 + BigdataService bigdataService;
  117 + @Autowired
  118 + BigscreenService bigscreenService;
  119 + @Autowired
  120 + StaffViewRealService staffViewRealService;
  121 + @Autowired
  122 + RateService rateService;
  123 +
  124 + @Bean
  125 + public Server rsServer() {
  126 + JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
  127 + endpoint.setBus(springBus());
  128 + endpoint.setAddress("/rest");
  129 + endpoint.setServiceBeans(Arrays.<Object>asList(
  130 + new LineRestService(),
  131 + new CarRestService(),
  132 + new PersonRestService(),
  133 + gpsRestService,
  134 + waybillRestService,
  135 + scheduleRealService,
  136 + stationRestService,
  137 + ldSectionRestService,
  138 + schedulePlanService,
  139 + realLogRestService,
  140 + directiveRestService,
  141 + ld_roadSpeedRestService,
  142 + electricService,
  143 + staffViewRealService,
  144 + bigdataService,
  145 + bigscreenService,
  146 + rateService));
  147 + endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new AesExceptionMapper()));
  148 + //endpoint.setFeatures(Arrays.asList(new Swagger2Feature()));
  149 + endpoint.getInInterceptors().add(new AuthorizeInterceptor_IN());
  150 + return endpoint.create();
  151 + }
  152 +
  153 + @Bean
  154 + public ServletRegistrationBean servletRegistrationBean() {
  155 + ServletRegistrationBean bean = new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
  156 + bean.setLoadOnStartup(0);
  157 + bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
  158 + return bean;
  159 + }
  160 +}