diff --git a/airline/client/jms/pom.xml b/airline/client/jms/pom.xml
index 80388cb..7edc491 100644
--- a/airline/client/jms/pom.xml
+++ b/airline/client/jms/pom.xml
@@ -39,8 +39,8 @@
- org.apache.activemq
- artemis-jakarta-client
+ org.springframework.boot
+ spring-boot-starter-artemis
diff --git a/airline/client/jms/src/main/java/org/springframework/ws/samples/airline/client/jms/JmsConfiguration.java b/airline/client/jms/src/main/java/org/springframework/ws/samples/airline/client/jms/JmsConfiguration.java
index 4016e70..ad8079e 100644
--- a/airline/client/jms/src/main/java/org/springframework/ws/samples/airline/client/jms/JmsConfiguration.java
+++ b/airline/client/jms/src/main/java/org/springframework/ws/samples/airline/client/jms/JmsConfiguration.java
@@ -18,7 +18,6 @@ package org.springframework.ws.samples.airline.client.jms;
import jakarta.jms.ConnectionFactory;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ws.transport.jms.JmsMessageSender;
@@ -31,11 +30,6 @@ import org.springframework.ws.transport.jms.JmsMessageSender;
@Configuration(proxyBeanMethods = false)
public class JmsConfiguration {
- @Bean
- ConnectionFactory connectionFactory() {
- return new ActiveMQConnectionFactory("tcp://localhost:61616");
- }
-
@Bean
JmsMessageSender jmsMessageSender(ConnectionFactory connectionFactory) {
return new JmsMessageSender(connectionFactory);
diff --git a/airline/client/jms/src/main/java/org/springframework/ws/samples/airline/client/jms/JmsMain.java b/airline/client/jms/src/main/java/org/springframework/ws/samples/airline/client/jms/JmsMain.java
index 2257462..6fb5c6e 100644
--- a/airline/client/jms/src/main/java/org/springframework/ws/samples/airline/client/jms/JmsMain.java
+++ b/airline/client/jms/src/main/java/org/springframework/ws/samples/airline/client/jms/JmsMain.java
@@ -16,19 +16,27 @@
package org.springframework.ws.samples.airline.client.jms;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
/**
* "Main" that creates a {@link JmsClient} and uses it to talk to the SOAP-based server.
*
* @author Greg Turnquist
*/
+@SpringBootApplication
public class JmsMain {
public static void main(String[] args) {
+ SpringApplication.run(JmsMain.class);
+ }
- AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(JmsConfiguration.class);
-
- ctx.getBean(JmsClient.class).getFlights();
+ @Bean
+ CommandLineRunner getFlights(JmsClient client) {
+ return args -> {
+ client.getFlights();
+ };
}
}
diff --git a/airline/client/jms/src/main/resources/application.properties b/airline/client/jms/src/main/resources/application.properties
new file mode 100644
index 0000000..5da42a1
--- /dev/null
+++ b/airline/client/jms/src/main/resources/application.properties
@@ -0,0 +1,3 @@
+logging.level.org.springframework.jms=DEBUG
+logging.level.org.springframework.ws=DEBUG
+#logging.level.org.apache.activemq=DEBUG
diff --git a/airline/client/jms/src/main/resources/log4j.properties b/airline/client/jms/src/main/resources/log4j.properties
deleted file mode 100644
index ef74297..0000000
--- a/airline/client/jms/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-log4j.rootLogger=WARN, stdout
-log4j.logger.org.springframework.ws=DEBUG
-
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
\ No newline at end of file
diff --git a/airline/server/pom.xml b/airline/server/pom.xml
index 916333e..a5d13b3 100644
--- a/airline/server/pom.xml
+++ b/airline/server/pom.xml
@@ -17,14 +17,11 @@
Demo project for Spring Web Services
- 1.8
- 2.10.6
2.15.0
${project.basedir}/target/generated-sources/axis
${project.basedir}/target/classes
${project.basedir}/../airline.wsdl
2.0.2
- 3.0
@@ -39,52 +36,16 @@
spring-boot-starter-web-services
-
- org.springframework.ws
- spring-ws-security
-
-
- com.sun.xml.wsit
- wsit-rt
-
-
- com.sun.xml.wsit
- xws-security
-
-
-
-
-
- com.sun.xml.wss
- xws-security
- ${xws-security.version}
-
-
- javax.activation
- activation
-
-
- javax.xml.crypto
- xmldsig
-
-
- javax.xml.bind
- jaxb-api
-
-
- javax.xml.stream
- stax-api
-
-
- javax.xml.ws
- jaxws-api
-
-
- javax.mail
- mail
-
-
-
+
+
+
+
+
+
+
+
+
+
org.springframework.ws
@@ -96,11 +57,6 @@
wsdl4j
-
- org.springframework.boot
- spring-boot-starter-security
-
-
org.springframework.boot
spring-boot-starter-data-jpa
@@ -121,26 +77,19 @@
org.springframework.boot
- spring-boot-starter-activemq
+ spring-boot-starter-artemis
-
- org.apache.activemq
- activemq-kahadb-store
- runtime
-
+
+ org.apache.activemq
+ artemis-jakarta-server
+
org.springframework.boot
spring-boot-starter-thymeleaf
-
- joda-time
- joda-time
- ${joda-time.version}
-
-
org.springframework
spring-test
@@ -151,12 +100,6 @@
org.springframework.boot
spring-boot-starter-test
test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
@@ -173,7 +116,7 @@
org.codehaus.mojo
jaxb2-maven-plugin
- 2.5.0
+ 3.1.0
xjc
@@ -185,7 +128,7 @@
${project.basedir}/src/main/resources/messages.xsd
org.springframework.ws.samples.airline.schema
- 2.1
+ 3.0
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/AirlineServerApplication.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/AirlineServerApplication.java
index 1d52b3e..c49df5d 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/AirlineServerApplication.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/AirlineServerApplication.java
@@ -2,9 +2,8 @@ package org.springframework.ws.samples.airline;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
-@SpringBootApplication(exclude = SecurityAutoConfiguration.class)
+@SpringBootApplication
public class AirlineServerApplication {
public static void main(String[] args) {
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/dao/Databaseinit.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/dao/Databaseinit.java
index b31db40..2e20dae 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/dao/Databaseinit.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/dao/Databaseinit.java
@@ -1,6 +1,8 @@
package org.springframework.ws.samples.airline.dao;
-import org.joda.time.DateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -22,9 +24,9 @@ public class Databaseinit {
Flight flight = new Flight();
flight.setNumber("KL1653");
- flight.setDepartureTime(new DateTime(2006, 1, 31, 10, 5, 0, 0).toGregorianCalendar().toZonedDateTime());
+ flight.setDepartureTime(ZonedDateTime.of(2006, 1, 31, 10, 5, 0, 0, ZoneId.systemDefault()));
flight.setFrom(amsterdam);
- flight.setArrivalTime(new DateTime(2006, 1, 31, 12, 25, 0, 0).toGregorianCalendar().toZonedDateTime());
+ flight.setArrivalTime(ZonedDateTime.of(2006, 1, 31, 12, 25, 0, 0, ZoneId.systemDefault()));
flight.setTo(venice);
flight.setServiceClass(ServiceClass.ECONOMY);
flight.setSeatsAvailable(5);
@@ -34,9 +36,9 @@ public class Databaseinit {
flight = new Flight();
flight.setNumber("KL1654");
- flight.setDepartureTime(new DateTime(2006, 2, 5, 12, 40, 0, 0).toGregorianCalendar().toZonedDateTime());
+ flight.setDepartureTime(ZonedDateTime.of(2006, 2, 5, 12, 40, 0, 0, ZoneId.systemDefault()));
flight.setFrom(venice);
- flight.setArrivalTime(new DateTime(2006, 2, 5, 14, 15, 0, 0).toGregorianCalendar().toZonedDateTime());
+ flight.setArrivalTime(ZonedDateTime.of(2006, 2, 5, 14, 15, 0, 0, ZoneId.systemDefault()));
flight.setTo(amsterdam);
flight.setServiceClass(ServiceClass.ECONOMY);
flight.setSeatsAvailable(5);
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/dao/FlightDao.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/dao/FlightDao.java
index 0edecba..6e3c2b0 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/dao/FlightDao.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/dao/FlightDao.java
@@ -18,7 +18,6 @@ package org.springframework.ws.samples.airline.dao;
import java.time.ZonedDateTime;
import java.util.List;
-import org.joda.time.Interval;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
@@ -28,29 +27,12 @@ import org.springframework.ws.samples.airline.domain.ServiceClass;
public interface FlightDao extends CrudRepository {
@Query("SELECT f FROM Flight f WHERE f.from.code = :fromAirportCode "
- + "AND f.to.code = :toAirportCode AND f.departureTime >= :#{#interval.start.toGregorianCalendar().toZonedDateTime()} AND f.departureTime <= :#{#interval.end.toGregorianCalendar().toZonedDateTime()} AND "
+ + "AND f.to.code = :toAirportCode AND f.departureTime >= :#{#date} AND f.departureTime <= :#{#date.plusDays(1)} AND "
+ "f.serviceClass = :class")
List findFlights(@Param("fromAirportCode") String fromAirportCode, //
- @Param("toAirportCode") String toAirportCode, //
- @Param("interval") Interval interval, //
- @Param("class") ServiceClass serviceClass);
-
- /**
- * @deprecated Migrate to {@link #findById(Object)}.
- */
- default Flight getFlight(Long id) {
- return findById(id).get();
- }
-
- ;
-
- /**
- * @deprecated Migrate to {@link #findFlightByNumberAndDepartureTime(String, ZonedDateTime)}.
- */
- @Deprecated
- default Flight getFlight(String flightNumber, ZonedDateTime departureTime) {
- return findFlightByNumberAndDepartureTime(flightNumber, departureTime);
- }
+ @Param("toAirportCode") String toAirportCode, //
+ @Param("date") ZonedDateTime date, //
+ @Param("class") ServiceClass serviceClass);
Flight findFlightByNumberAndDepartureTime(String flightNumber, ZonedDateTime departureTime);
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Airport.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Airport.java
index ce55810..9b9c778 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Airport.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Airport.java
@@ -16,60 +16,56 @@
package org.springframework.ws.samples.airline.domain;
-import java.io.Serializable;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import java.io.Serializable;
@Entity
@Table(name = "AIRPORT")
public class Airport implements Serializable {
- @Id
- @Column(name = "CODE")
- private String code;
+ @Id
+ @Column(name = "CODE") private String code;
- @Column(name = "NAME")
- private String name;
+ @Column(name = "NAME") private String name;
- @Column(name = "CITY")
- private String city;
+ @Column(name = "CITY") private String city;
- public Airport() {
- }
+ public Airport() {}
- public Airport(String code, String name, String city) {
- this.code = code;
- this.name = name;
- this.city = city;
- }
+ public Airport(String code, String name, String city) {
+ this.code = code;
+ this.name = name;
+ this.city = city;
+ }
- public String getCity() {
- return city;
- }
+ public String getCity() {
+ return city;
+ }
- public String getCode() {
- return code;
- }
+ public String getCode() {
+ return code;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
- if (!(other instanceof Airport)) {
- return false;
- }
- final Airport that = (Airport) other;
- return code.equals(that.code);
- }
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+ if (!(other instanceof Airport)) {
+ return false;
+ }
+ final Airport that = (Airport) other;
+ return code.equals(that.code);
+ }
- public int hashCode() {
- return code.hashCode();
- }
+ public int hashCode() {
+ return code.hashCode();
+ }
}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Flight.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Flight.java
index 32d7d17..8a66933 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Flight.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Flight.java
@@ -15,39 +15,37 @@
*/
package org.springframework.ws.samples.airline.domain;
+import jakarta.persistence.*;
+
import java.io.Serializable;
import java.time.ZonedDateTime;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-
import org.springframework.data.annotation.Persistent;
@Entity
@Table(name = "FLIGHT")
public class Flight implements Serializable {
- @Id @Column(name = "ID") @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
+ @Id
+ @Column(name = "ID")
+ @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
@Column(name = "NUMBER") private String number;
- @Column(name = "DEPARTURE_TIME") @Persistent private ZonedDateTime departureTime;
+ @Column(name = "DEPARTURE_TIME")
+ @Persistent private ZonedDateTime departureTime;
- @ManyToOne @JoinColumn(name = "FROM_AIRPORT_CODE", nullable = false) private Airport from;
+ @ManyToOne
+ @JoinColumn(name = "FROM_AIRPORT_CODE", nullable = false) private Airport from;
- @Column(name = "ARRIVAL_TIME") @Persistent private ZonedDateTime arrivalTime;
+ @Column(name = "ARRIVAL_TIME")
+ @Persistent private ZonedDateTime arrivalTime;
- @ManyToOne @JoinColumn(name = "TO_AIRPORT_CODE", nullable = false) private Airport to;
+ @ManyToOne
+ @JoinColumn(name = "TO_AIRPORT_CODE", nullable = false) private Airport to;
- @Column(name = "SERVICE_CLASS") @Enumerated(EnumType.STRING) private ServiceClass serviceClass;
+ @Column(name = "SERVICE_CLASS")
+ @Enumerated(EnumType.STRING) private ServiceClass serviceClass;
@Column(name = "SEATS_AVAILABLE") private int seatsAvailable;
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/FrequentFlyer.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/FrequentFlyer.java
index a1ea89e..42d541f 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/FrequentFlyer.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/FrequentFlyer.java
@@ -16,10 +16,10 @@
package org.springframework.ws.samples.airline.domain;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.PrimaryKeyJoinColumn;
-import javax.persistence.Table;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.PrimaryKeyJoinColumn;
+import jakarta.persistence.Table;
@Entity
@Table(name = "FREQUENT_FLYER")
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Passenger.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Passenger.java
index 462b167..117712a 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Passenger.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Passenger.java
@@ -15,86 +15,75 @@
*/
package org.springframework.ws.samples.airline.domain;
-import java.io.Serializable;
+import jakarta.persistence.*;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Inheritance;
-import javax.persistence.InheritanceType;
-import javax.persistence.Table;
+import java.io.Serializable;
@Entity
@Table(name = "PASSENGER")
@Inheritance(strategy = InheritanceType.JOINED)
public class Passenger implements Serializable {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "ID")
- private Long id;
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "ID") private Long id;
- @Column(name = "FIRST_NAME")
- private String firstName;
+ @Column(name = "FIRST_NAME") private String firstName;
- @Column(name = "LAST_NAME")
- private String lastName;
+ @Column(name = "LAST_NAME") private String lastName;
- public Passenger() {
- }
+ public Passenger() {}
- public Passenger(String firstName, String lastName) {
- this.firstName = firstName;
- this.lastName = lastName;
- }
+ public Passenger(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
- public Passenger(Long id, String firstName, String lastName) {
- this.id = id;
- this.firstName = firstName;
- this.lastName = lastName;
- }
+ public Passenger(Long id, String firstName, String lastName) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
- public String getFirstName() {
- return firstName;
- }
+ public String getFirstName() {
+ return firstName;
+ }
- public Long getId() {
- return id;
- }
+ public Long getId() {
+ return id;
+ }
- public String getLastName() {
- return lastName;
- }
+ public String getLastName() {
+ return lastName;
+ }
- public String toString() {
- return firstName + " " + lastName;
- }
+ public String toString() {
+ return firstName + " " + lastName;
+ }
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
- final Passenger passenger = (Passenger) o;
+ final Passenger passenger = (Passenger) o;
- if (!getFirstName().equals(passenger.getFirstName())) {
- return false;
- }
- if (!getLastName().equals(passenger.getLastName())) {
- return false;
- }
+ if (!getFirstName().equals(passenger.getFirstName())) {
+ return false;
+ }
+ if (!getLastName().equals(passenger.getLastName())) {
+ return false;
+ }
- return true;
- }
+ return true;
+ }
- public int hashCode() {
- int result = getFirstName().hashCode();
- result = 29 * result + getLastName().hashCode();
- return result;
- }
+ public int hashCode() {
+ int result = getFirstName().hashCode();
+ result = 29 * result + getLastName().hashCode();
+ return result;
+ }
}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Ticket.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Ticket.java
index 3e5abe2..40d08e7 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Ticket.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/domain/Ticket.java
@@ -16,23 +16,13 @@
package org.springframework.ws.samples.airline.domain;
+import jakarta.persistence.*;
+
import java.io.Serializable;
+import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-
-import org.joda.time.LocalDate;
import org.springframework.data.annotation.Persistent;
@Entity
@@ -40,25 +30,19 @@ import org.springframework.data.annotation.Persistent;
public class Ticket implements Serializable {
@Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
+ @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id;
@Column(name = "ISSUE_DATE")
- @Persistent
- private LocalDate issueDate;
+ @Persistent private LocalDate issueDate;
@ManyToOne
- @JoinColumn(name = "FLIGHT_ID", nullable = false)
- private Flight flight;
+ @JoinColumn(name = "FLIGHT_ID", nullable = false) private Flight flight;
- @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
- @JoinTable(name = "PASSENGER_TICKET",
- joinColumns = @JoinColumn(name = "TICKET_ID"),
- inverseJoinColumns = @JoinColumn(name = "PASSENGER_ID"))
- private Set passengers = new HashSet();
+ @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
+ @JoinTable(name = "PASSENGER_TICKET", joinColumns = @JoinColumn(name = "TICKET_ID"), inverseJoinColumns = @JoinColumn(
+ name = "PASSENGER_ID")) private Set passengers = new HashSet();
- public Ticket() {
- }
+ public Ticket() {}
public Ticket(Long id) {
this.id = id;
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/jms/JmsConfiguration.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/jms/JmsConfiguration.java
index b6f30af..b069be3 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/jms/JmsConfiguration.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/jms/JmsConfiguration.java
@@ -1,11 +1,12 @@
package org.springframework.ws.samples.airline.jms;
-import javax.jms.ConnectionFactory;
+import jakarta.jms.ConnectionFactory;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.core.remoting.impl.netty.NettyAcceptorFactory;
+import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQQueue;
+import org.springframework.boot.autoconfigure.jms.artemis.ArtemisConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
@@ -16,19 +17,21 @@ import org.springframework.ws.transport.jms.WebServiceMessageListener;
@Configuration
public class JmsConfiguration {
- @Bean(initMethod = "start")
- BrokerService broker() throws Exception {
- return BrokerFactory.createBroker("broker:tcp://localhost:61616?persistent=false");
- }
-
+ /**
+ * Make embedded ActiveMQ broker open to tcp connections.
+ */
@Bean
- ActiveMQConnectionFactory connectionFactory() {
-
- ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
- connectionFactory.setBrokerURL("tcp://localhost:61616");
- return connectionFactory;
+ ArtemisConfigurationCustomizer customizer() {
+ return configuration -> {
+ configuration.addConnectorConfiguration("nettyConnector",
+ new TransportConfiguration(NettyConnectorFactory.class.getName()));
+ configuration.addAcceptorConfiguration(new TransportConfiguration(NettyAcceptorFactory.class.getName()));
+ };
}
+ /**
+ * Listen for JMS messages and route them into the SOAP-based {@link WebServiceMessageListener}.
+ */
@Bean
DefaultMessageListenerContainer containerFactory(ConnectionFactory connectionFactory,
WebServiceMessageListener messageListener) {
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/schema/support/SchemaConversionUtils.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/schema/support/SchemaConversionUtils.java
index 4f10522..a95daf1 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/schema/support/SchemaConversionUtils.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/schema/support/SchemaConversionUtils.java
@@ -16,6 +16,7 @@
package org.springframework.ws.samples.airline.schema.support;
+import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.util.GregorianCalendar;
import java.util.List;
@@ -26,13 +27,8 @@ import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
-import org.joda.time.LocalDate;
import org.springframework.ws.samples.airline.domain.Passenger;
-import org.springframework.ws.samples.airline.schema.Airport;
-import org.springframework.ws.samples.airline.schema.Flight;
-import org.springframework.ws.samples.airline.schema.Name;
-import org.springframework.ws.samples.airline.schema.ServiceClass;
-import org.springframework.ws.samples.airline.schema.Ticket;
+import org.springframework.ws.samples.airline.schema.*;
/** @author Arjen Poutsma */
public abstract class SchemaConversionUtils {
@@ -79,12 +75,12 @@ public abstract class SchemaConversionUtils {
public static XMLGregorianCalendar toXMLGregorianCalendar(LocalDate localDate) throws DatatypeConfigurationException {
DatatypeFactory factory = DatatypeFactory.newInstance();
- return factory.newXMLGregorianCalendarDate(localDate.getYear(), localDate.getMonthOfYear(),
+ return factory.newXMLGregorianCalendarDate(localDate.getYear(), localDate.getMonthValue(),
localDate.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED);
}
public static LocalDate toLocalDate(XMLGregorianCalendar calendar) {
- return new LocalDate(calendar.getYear(), calendar.getMonth(), calendar.getDay());
+ return LocalDate.of(calendar.getYear(), calendar.getMonth(), calendar.getDay());
}
public static Airport toSchemaType(org.springframework.ws.samples.airline.domain.Airport domainAirport) {
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/FrequentFlyerDetails.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/security/FrequentFlyerDetails.java
deleted file mode 100644
index 82ca823..0000000
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/FrequentFlyerDetails.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.ws.samples.airline.security;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.ws.samples.airline.domain.FrequentFlyer;
-
-/**
- * A wrapper around an FrequentFlyer which provides extra functionality needed to implement the
- * UserDetails interface.
- *
- * @author Arjen Poutsma
- */
-public class FrequentFlyerDetails implements UserDetails {
-
- private FrequentFlyer frequentFlyer;
-
- public static final Collection GRANTED_AUTHORITIES =
- new ArrayList();
- {
- GRANTED_AUTHORITIES.add(new SimpleGrantedAuthority("ROLE_FREQUENT_FLYER"));
- };
-
- public FrequentFlyerDetails(FrequentFlyer frequentFlyer) {
- this.frequentFlyer = frequentFlyer;
- }
-
- public Collection getAuthorities() {
- return GRANTED_AUTHORITIES;
- }
-
- public String getPassword() {
- return frequentFlyer.getPassword();
- }
-
- public String getUsername() {
- return frequentFlyer.getUsername();
- }
-
- public boolean isAccountNonExpired() {
- return true;
- }
-
- public boolean isAccountNonLocked() {
- return true;
- }
-
- public boolean isCredentialsNonExpired() {
- return true;
- }
-
- public boolean isEnabled() {
- return true;
- }
-
- public FrequentFlyer getFrequentFlyer() {
- return frequentFlyer;
- }
-
- public String toString() {
- return frequentFlyer.toString();
- }
-}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/FrequentFlyerSecurityService.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/security/FrequentFlyerSecurityService.java
deleted file mode 100644
index 5f442ea..0000000
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/FrequentFlyerSecurityService.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.ws.samples.airline.security;
-
-import org.springframework.ws.samples.airline.domain.FrequentFlyer;
-import org.springframework.ws.samples.airline.service.NoSuchFrequentFlyerException;
-
-/**
- * Defines the business logic for handling frequent flyers.
- *
- * @author Arjen Poutsma
- */
-public interface FrequentFlyerSecurityService {
-
- /**
- * Returns the FrequentFlyer with the given username.
- *
- * @param username the username
- * @return the frequent flyer with the given username, or null if not found
- * @throws NoSuchFrequentFlyerException when the frequent flyer cannot be found
- */
- FrequentFlyer getFrequentFlyer(String username) throws NoSuchFrequentFlyerException;
-
- /**
- * Returns the FrequentFlyer that is currently logged in.
- *
- * @return the frequent flyer that is currently logged in, or null if not found
- */
- FrequentFlyer getCurrentlyAuthenticatedFrequentFlyer();
-
-}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/SecurityConfiguration.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/security/SecurityConfiguration.java
deleted file mode 100644
index 63272b0..0000000
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/SecurityConfiguration.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.springframework.ws.samples.airline.security;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.bytebuddy.build.Plugin;
-import org.springframework.context.annotation.Bean;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.authentication.ProviderManager;
-import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
-import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
-import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
-import org.springframework.security.crypto.password.NoOpPasswordEncoder;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.ws.samples.airline.dao.FrequentFlyerDao;
-
-@EnableGlobalMethodSecurity(securedEnabled = true)
-public class SecurityConfiguration /*extends WebSecurityConfigurerAdapter*/ {
-
- @Bean
- SpringFrequentFlyerSecurityService securityService(FrequentFlyerDao frequentFlyerDao) {
- return new SpringFrequentFlyerSecurityService(frequentFlyerDao);
- }
-
- @Bean
- AuthenticationManager authenticationManager(SpringFrequentFlyerSecurityService securityService) {
-
- DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
- authenticationProvider.setUserDetailsService(securityService);
- return new ProviderManager(authenticationProvider);
- }
-
- @Bean
- PasswordEncoder passwordEncoder() {
- return NoOpPasswordEncoder.getInstance();
- }
-}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/SpringFrequentFlyerSecurityService.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/security/SpringFrequentFlyerSecurityService.java
deleted file mode 100644
index c709a84..0000000
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/SpringFrequentFlyerSecurityService.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2005-2011 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.ws.samples.airline.security;
-
-import org.springframework.dao.DataAccessException;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.ws.samples.airline.dao.FrequentFlyerDao;
-import org.springframework.ws.samples.airline.domain.FrequentFlyer;
-import org.springframework.ws.samples.airline.service.NoSuchFrequentFlyerException;
-
-/**
- * Implementation of the FrequentFlyerSecurityService that uses Spring Security.
- *
- * @author Arjen Poutsma
- */
-public class SpringFrequentFlyerSecurityService implements FrequentFlyerSecurityService, UserDetailsService {
-
- private FrequentFlyerDao frequentFlyerDao;
-
- public SpringFrequentFlyerSecurityService(FrequentFlyerDao frequentFlyerDao) {
- this.frequentFlyerDao = frequentFlyerDao;
- }
-
- @Transactional
- public FrequentFlyer getCurrentlyAuthenticatedFrequentFlyer() {
-
- SecurityContext context = SecurityContextHolder.getContext();
- Authentication authentication = context.getAuthentication();
- if (authentication != null) {
- if (authentication.getPrincipal() instanceof FrequentFlyerDetails) {
- FrequentFlyerDetails details = (FrequentFlyerDetails) authentication.getPrincipal();
- return details.getFrequentFlyer();
- } else {
- return (FrequentFlyer) authentication.getPrincipal();
- }
- } else {
- return null;
- }
- }
-
- @Transactional
- public FrequentFlyer getFrequentFlyer(String username) throws NoSuchFrequentFlyerException {
-
- FrequentFlyer frequentFlyer = frequentFlyerDao.get(username);
- if (frequentFlyer != null) {
- return frequentFlyer;
- } else {
- throw new NoSuchFrequentFlyerException(username);
- }
- }
-
- @Transactional
- public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
-
- FrequentFlyer frequentFlyer = frequentFlyerDao.get(username);
- if (frequentFlyer != null) {
- return new FrequentFlyerDetails(frequentFlyer);
- } else {
- throw new UsernameNotFoundException("Frequent flyer '" + username + "' not found");
- }
- }
-}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/StubFrequentFlyerSecurityService.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/security/StubFrequentFlyerSecurityService.java
deleted file mode 100644
index b4c1f56..0000000
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/security/StubFrequentFlyerSecurityService.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.ws.samples.airline.security;
-
-import org.springframework.ws.samples.airline.domain.FrequentFlyer;
-import org.springframework.ws.samples.airline.service.NoSuchFrequentFlyerException;
-
-/**
- * Stub implementation of FrequentFlyerSecurityService. This implementation is used by default by {@link
- * org.springframework.ws.samples.airline.service.impl.AirlineServiceImpl}, to allow it to run without depending on
- * Spring Security.
- *
- * @author Arjen Poutsma
- */
-public class StubFrequentFlyerSecurityService implements FrequentFlyerSecurityService {
-
- private FrequentFlyer john;
-
- public StubFrequentFlyerSecurityService() {
- john = new FrequentFlyer("John", "Doe", "john", "changeme");
- john.setMiles(10);
- }
-
- public FrequentFlyer getFrequentFlyer(String username) throws NoSuchFrequentFlyerException {
- if (john.getUsername().equals(username)) {
- return john;
- }
- else {
- throw new NoSuchFrequentFlyerException(username);
- }
- }
-
- public FrequentFlyer getCurrentlyAuthenticatedFrequentFlyer() {
- return john;
- }
-}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/service/AirlineService.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/service/AirlineService.java
index 5835b99..ee047ae 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/service/AirlineService.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/service/AirlineService.java
@@ -18,12 +18,7 @@ package org.springframework.ws.samples.airline.service;
import java.time.ZonedDateTime;
import java.util.List;
-import org.joda.time.LocalDate;
-import org.springframework.ws.samples.airline.domain.Flight;
-import org.springframework.ws.samples.airline.domain.FrequentFlyer;
-import org.springframework.ws.samples.airline.domain.Passenger;
-import org.springframework.ws.samples.airline.domain.ServiceClass;
-import org.springframework.ws.samples.airline.domain.Ticket;
+import org.springframework.ws.samples.airline.domain.*;
/**
* Defines the business logic of the Airline application.
@@ -32,52 +27,43 @@ import org.springframework.ws.samples.airline.domain.Ticket;
*/
public interface AirlineService {
- /**
- * Returns a single Flight with the given id.
- *
- * @param id the flight identifier
- * @return the flight
- * @throws NoSuchFlightException if a flight with the specified flight iddoes not exist
- */
- Flight getFlight(Long id) throws NoSuchFlightException;
+ /**
+ * Returns a single Flight with the given id.
+ *
+ * @param id the flight identifier
+ * @return the flight
+ * @throws NoSuchFlightException if a flight with the specified flight iddoes not exist
+ */
+ Flight getFlight(Long id) throws NoSuchFlightException;
- /**
- * Returns a list of Flight objects that fall within the specified criteria.
- *
- * @param fromAirportCode the three-letter airport code to get flights from
- * @param toAirportCode the three-letter airport code to get flights to
- * @param departureDate the date of the flights
- * @param serviceClass the desired service class level. May be null
- * @return a list of flights
- */
- List getFlights(String fromAirportCode,
- String toAirportCode,
- LocalDate departureDate,
- ServiceClass serviceClass);
+ /**
+ * Returns a list of Flight objects that fall within the specified criteria.
+ *
+ * @param fromAirportCode the three-letter airport code to get flights from
+ * @param toAirportCode the three-letter airport code to get flights to
+ * @param departureDate the date of the flights
+ * @param serviceClass the desired service class level. May be null
+ * @return a list of flights
+ */
+ List getFlights(String fromAirportCode, String toAirportCode, ZonedDateTime departureDate,
+ ServiceClass serviceClass);
- /**
- * Books a single flight for a number of passengers. Passengers can be either specified by name or by frequent flyer
- * username. If a {@link FrequentFlyer} is specified, the first and last name are looked up in the database.
- *
- * @param flightNumber the number of the flight to book
- * @param departureTime the departure time of the flight to book
- * @param passengers the list of passengers for the flight to book. Can be either {@link Passenger} objects with
- * a first and last name, or {@link FrequentFlyer} objects with a username.
- * @return the created ticket
- * @throws NoSuchFlightException if a flight with the specified flight number and departure time does not
- * exist
- * @throws NoSeatAvailableException if not enough seats are available for the flight
- * @throws NoSuchFrequentFlyerException if a specified {@link FrequentFlyer} cannot be found
- * @see Passenger
- * @see FrequentFlyer
- */
- Ticket bookFlight(String flightNumber, ZonedDateTime departureTime, List passengers)
- throws NoSuchFlightException, NoSeatAvailableException, NoSuchFrequentFlyerException;
+ /**
+ * Books a single flight for a number of passengers. Passengers can be either specified by name or by frequent flyer
+ * username. If a {@link FrequentFlyer} is specified, the first and last name are looked up in the database.
+ *
+ * @param flightNumber the number of the flight to book
+ * @param departureTime the departure time of the flight to book
+ * @param passengers the list of passengers for the flight to book. Can be either {@link Passenger} objects with a
+ * first and last name, or {@link FrequentFlyer} objects with a username.
+ * @return the created ticket
+ * @throws NoSuchFlightException if a flight with the specified flight number and departure time does not exist
+ * @throws NoSeatAvailableException if not enough seats are available for the flight
+ * @throws NoSuchFrequentFlyerException if a specified {@link FrequentFlyer} cannot be found
+ * @see Passenger
+ * @see FrequentFlyer
+ */
+ Ticket bookFlight(String flightNumber, ZonedDateTime departureTime, List passengers)
+ throws NoSuchFlightException, NoSeatAvailableException, NoSuchFrequentFlyerException;
- /**
- * Returns the amount of frequent flyer award miles for the currently logged in frequent flyer.
- *
- * @return the amount of frequent flyer miles
- */
- int getFrequentFlyerMileage();
}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/service/impl/AirlineServiceImpl.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/service/impl/AirlineServiceImpl.java
index 9680689..e889195 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/service/impl/AirlineServiceImpl.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/service/impl/AirlineServiceImpl.java
@@ -15,26 +15,22 @@
*/
package org.springframework.ws.samples.airline.service.impl;
+import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.joda.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.ws.samples.airline.dao.FlightDao;
import org.springframework.ws.samples.airline.dao.TicketDao;
import org.springframework.ws.samples.airline.domain.Flight;
-import org.springframework.ws.samples.airline.domain.FrequentFlyer;
import org.springframework.ws.samples.airline.domain.Passenger;
import org.springframework.ws.samples.airline.domain.ServiceClass;
import org.springframework.ws.samples.airline.domain.Ticket;
-import org.springframework.ws.samples.airline.security.FrequentFlyerSecurityService;
-import org.springframework.ws.samples.airline.security.StubFrequentFlyerSecurityService;
import org.springframework.ws.samples.airline.service.AirlineService;
import org.springframework.ws.samples.airline.service.NoSeatAvailableException;
import org.springframework.ws.samples.airline.service.NoSuchFlightException;
@@ -55,8 +51,6 @@ public class AirlineServiceImpl implements AirlineService {
private TicketDao ticketDao;
- private FrequentFlyerSecurityService frequentFlyerSecurityService = new StubFrequentFlyerSecurityService();
-
@Autowired
public AirlineServiceImpl(FlightDao flightDao, TicketDao ticketDao) {
@@ -64,11 +58,6 @@ public class AirlineServiceImpl implements AirlineService {
this.ticketDao = ticketDao;
}
- @Autowired(required = false)
- public void setFrequentFlyerSecurityService(FrequentFlyerSecurityService frequentFlyerSecurityService) {
- this.frequentFlyerSecurityService = frequentFlyerSecurityService;
- }
-
@Transactional(readOnly = false,
rollbackFor = { NoSuchFlightException.class, NoSeatAvailableException.class, NoSuchFrequentFlyerException.class })
public Ticket bookFlight(String flightNumber, ZonedDateTime departureTime, List passengers)
@@ -78,44 +67,27 @@ public class AirlineServiceImpl implements AirlineService {
if (logger.isDebugEnabled()) {
logger.debug("Booking flight '" + flightNumber + "' on '" + departureTime + "' for " + passengers);
}
- Flight flight = flightDao.getFlight(flightNumber, departureTime);
+ Flight flight = flightDao.findFlightByNumberAndDepartureTime(flightNumber, departureTime);
if (flight == null) {
throw new NoSuchFlightException(flightNumber, departureTime);
} else if (flight.getSeatsAvailable() < passengers.size()) {
throw new NoSeatAvailableException(flight);
}
Ticket ticket = new Ticket();
- ticket.setIssueDate(new LocalDate());
+ ticket.setIssueDate(LocalDate.now());
ticket.setFlight(flight);
- for (Passenger passenger : passengers) {
- // frequent flyer service is not required
- if (passenger instanceof FrequentFlyer && frequentFlyerSecurityService != null) {
- String username = ((FrequentFlyer) passenger).getUsername();
- Assert.hasLength(username, "No username specified");
- FrequentFlyer frequentFlyer = frequentFlyerSecurityService.getFrequentFlyer(username);
- frequentFlyer.addMiles(flight.getMiles());
- ticket.addPassenger(frequentFlyer);
- } else {
- ticket.addPassenger(passenger);
- }
- }
+ passengers.forEach(ticket::addPassenger);
flight.substractSeats(passengers.size());
- flightDao.update(flight);
+ flightDao.save(flight);
ticketDao.save(ticket);
return ticket;
}
public Flight getFlight(Long id) throws NoSuchFlightException {
-
- Flight flight = flightDao.getFlight(id);
- if (flight != null) {
- return flight;
- } else {
- throw new NoSuchFlightException(id);
- }
+ return flightDao.findById(id).orElseThrow(() -> new NoSuchFlightException(id));
}
- public List getFlights(String fromAirportCode, String toAirportCode, LocalDate departureDate,
+ public List getFlights(String fromAirportCode, String toAirportCode, ZonedDateTime departureDate,
ServiceClass serviceClass) {
if (serviceClass == null) {
@@ -124,21 +96,10 @@ public class AirlineServiceImpl implements AirlineService {
if (logger.isDebugEnabled()) {
logger.debug("Getting flights from '" + fromAirportCode + "' to '" + toAirportCode + "' on " + departureDate);
}
- List flights = flightDao.findFlights(fromAirportCode, toAirportCode, departureDate.toInterval(),
- serviceClass);
+ List flights = flightDao.findFlights(fromAirportCode, toAirportCode, departureDate, serviceClass);
if (logger.isDebugEnabled()) {
logger.debug("Returning " + flights.size() + " flights");
}
return flights;
}
-
- @Secured({ "ROLE_FREQUENT_FLYER" })
- public int getFrequentFlyerMileage() {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Using " + frequentFlyerSecurityService + " for security");
- }
- FrequentFlyer frequentFlyer = frequentFlyerSecurityService.getCurrentlyAuthenticatedFrequentFlyer();
- return frequentFlyer != null ? frequentFlyer.getMiles() : 0;
- }
}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/web/FlightsController.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/web/FlightsController.java
index 0518fd7..3ed09a1 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/web/FlightsController.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/web/FlightsController.java
@@ -16,10 +16,13 @@
package org.springframework.ws.samples.airline.web;
-import org.joda.time.LocalDate;
+import java.time.LocalDate;
+import java.time.ZonedDateTime;
+
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.Assert;
+import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -48,14 +51,14 @@ public class FlightsController {
@RequestParam(value = "departureDate", required = false) String departureDateString,
@RequestParam(value = "serviceClass", required = false) String serviceClassString, ModelMap model) {
- if (StringUtils.isEmpty(departureDateString)) {
- departureDateString = new LocalDate().toString();
+ if (ObjectUtils.isEmpty(departureDateString)) {
+ departureDateString = LocalDate.now().toString();
}
- if (StringUtils.isEmpty(serviceClassString)) {
+ if (ObjectUtils.isEmpty(serviceClassString)) {
serviceClassString = "ECONOMY";
}
ServiceClass serviceClass = ServiceClass.valueOf(serviceClassString);
- LocalDate departureDate = new LocalDate(departureDateString);
+ ZonedDateTime departureDate = ZonedDateTime.parse(departureDateString);
if (StringUtils.hasLength(fromAirportCode) && StringUtils.hasLength(toAirportCode)) {
model.addAttribute("from", fromAirportCode);
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/AirlineEndpoint.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/AirlineEndpoint.java
index 203d539..5f78e98 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/AirlineEndpoint.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/AirlineEndpoint.java
@@ -18,43 +18,33 @@ package org.springframework.ws.samples.airline.ws;
import static org.springframework.ws.samples.airline.ws.AirlineWebServiceConstants.*;
+import jakarta.xml.bind.JAXBElement;
+
+import java.time.LocalDate;
+import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import javax.xml.bind.JAXBElement;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar;
-import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.joda.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.ws.samples.airline.domain.FrequentFlyer;
import org.springframework.ws.samples.airline.domain.Passenger;
import org.springframework.ws.samples.airline.domain.ServiceClass;
-import org.springframework.ws.samples.airline.schema.BookFlightRequest;
-import org.springframework.ws.samples.airline.schema.GetFlightsResponse;
-import org.springframework.ws.samples.airline.schema.Name;
-import org.springframework.ws.samples.airline.schema.ObjectFactory;
-import org.springframework.ws.samples.airline.schema.Ticket;
+import org.springframework.ws.samples.airline.schema.*;
import org.springframework.ws.samples.airline.schema.support.SchemaConversionUtils;
import org.springframework.ws.samples.airline.service.AirlineService;
import org.springframework.ws.samples.airline.service.NoSeatAvailableException;
import org.springframework.ws.samples.airline.service.NoSuchFlightException;
import org.springframework.ws.samples.airline.service.NoSuchFrequentFlyerException;
-import org.springframework.ws.server.endpoint.annotation.Endpoint;
-import org.springframework.ws.server.endpoint.annotation.Namespace;
-import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
-import org.springframework.ws.server.endpoint.annotation.RequestPayload;
-import org.springframework.ws.server.endpoint.annotation.ResponsePayload;
-import org.springframework.ws.server.endpoint.annotation.XPathParam;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import org.springframework.ws.server.endpoint.annotation.*;
/**
* Endpoint that handles the Airline Web Service messages using a combination of JAXB2 marshalling and XPath
@@ -99,7 +89,7 @@ public class AirlineEndpoint {
logger.debug("Received GetFlightsRequest '" + from + "' to '" + to + "' on " + departureDateString);
}
- LocalDate departureDate = new LocalDate(departureDateString);
+ ZonedDateTime departureDate = LocalDate.parse(departureDateString).atStartOfDay(ZoneId.systemDefault());
ServiceClass serviceClass = null;
if (StringUtils.hasLength(serviceClassString)) {
@@ -165,22 +155,4 @@ public class AirlineEndpoint {
return SchemaConversionUtils.toSchemaType(domainTicket);
}
-
- @PayloadRoot(localPart = GET_FREQUENT_FLYER_MILEAGE_REQUEST, namespace = MESSAGES_NAMESPACE)
- @ResponsePayload
- public Element getFrequentFlyerMileage() throws Exception {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Received GetFrequentFlyerMileageRequest");
- }
-
- int mileage = airlineService.getFrequentFlyerMileage();
- DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
- Document document = documentBuilder.newDocument();
- Element response = document.createElementNS(MESSAGES_NAMESPACE, GET_FREQUENT_FLYER_MILEAGE_RESPONSE);
- response.setTextContent(Integer.toString(mileage));
-
- return response;
- }
-
}
diff --git a/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/WebServicesConfiguration.java b/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/WebServicesConfiguration.java
index e2daf54..4b5866f 100644
--- a/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/WebServicesConfiguration.java
+++ b/airline/server/src/main/java/org/springframework/ws/samples/airline/ws/WebServicesConfiguration.java
@@ -8,14 +8,10 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
-import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.util.MimeTypeUtils;
import org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor;
import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;
-import org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor;
-import org.springframework.ws.soap.security.xwss.callback.SpringDigestPasswordValidationCallbackHandler;
import org.springframework.ws.soap.server.SoapMessageDispatcher;
-import org.springframework.ws.soap.server.endpoint.interceptor.PayloadRootSmartSoapEndpointInterceptor;
import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor;
import org.springframework.ws.transport.http.MessageDispatcherServlet;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
@@ -60,33 +56,33 @@ public class WebServicesConfiguration {
return payloadValidatingInterceptor;
}
- @Bean
- XwsSecurityInterceptor securityInterceptor(UserDetailsService securityService) {
+// @Bean
+// XwsSecurityInterceptor securityInterceptor(UserDetailsService securityService) {
+//
+// XwsSecurityInterceptor securityInterceptor = new XwsSecurityInterceptor();
+// securityInterceptor.setSecureResponse(false);
+// securityInterceptor.setPolicyConfiguration(
+// new ClassPathResource("org/springframework/ws/samples/airline/security/securityPolicy.xml"));
+// securityInterceptor.setCallbackHandler(springDigestPasswordValidationCallbackHandler(securityService));
+//
+// return securityInterceptor;
+// }
- XwsSecurityInterceptor securityInterceptor = new XwsSecurityInterceptor();
- securityInterceptor.setSecureResponse(false);
- securityInterceptor.setPolicyConfiguration(
- new ClassPathResource("org/springframework/ws/samples/airline/security/securityPolicy.xml"));
- securityInterceptor.setCallbackHandler(springDigestPasswordValidationCallbackHandler(securityService));
+// @Bean
+// PayloadRootSmartSoapEndpointInterceptor smartSoapEndpointInterceptor(XwsSecurityInterceptor securityInterceptor) {
+//
+// return new PayloadRootSmartSoapEndpointInterceptor(securityInterceptor,
+// "http://www.springframework.org/spring-ws/samples/airline/schemas/messages", "GetFrequentFlyerMileageRequest");
+// }
- return securityInterceptor;
- }
-
- @Bean
- PayloadRootSmartSoapEndpointInterceptor smartSoapEndpointInterceptor(XwsSecurityInterceptor securityInterceptor) {
-
- return new PayloadRootSmartSoapEndpointInterceptor(securityInterceptor,
- "http://www.springframework.org/spring-ws/samples/airline/schemas/messages", "GetFrequentFlyerMileageRequest");
- }
-
- @Bean
- SpringDigestPasswordValidationCallbackHandler springDigestPasswordValidationCallbackHandler(
- UserDetailsService securityService) {
-
- SpringDigestPasswordValidationCallbackHandler handler = new SpringDigestPasswordValidationCallbackHandler();
- handler.setUserDetailsService(securityService);
- return handler;
- }
+// @Bean
+// SpringDigestPasswordValidationCallbackHandler springDigestPasswordValidationCallbackHandler(
+// UserDetailsService securityService) {
+//
+// SpringDigestPasswordValidationCallbackHandler handler = new SpringDigestPasswordValidationCallbackHandler();
+// handler.setUserDetailsService(securityService);
+// return handler;
+// }
@Bean
SaajSoapMessageFactory messageFactory() {
diff --git a/airline/server/src/main/resources/application.properties b/airline/server/src/main/resources/application.properties
index 0f447a3..9fe8aba 100644
--- a/airline/server/src/main/resources/application.properties
+++ b/airline/server/src/main/resources/application.properties
@@ -1,3 +1,5 @@
logging.level.org.springframework.data=DEBUG
-logging.level.org.springframework.ws=DEBUG
logging.level.org.springframework.web=DEBUG
+logging.level.org.springframework.jms=DEBUG
+logging.level.org.springframework.ws=DEBUG
+#logging.level.org.apache.activemq=DEBUG