BAEL-553 - Intro to Spring Remoting with HTTP Invokers (#998)
* First test with log4j rolling appenders * small fix * Log4j rolling appender * First set up with rolling file on log4j 2 * Added logback code. * log4j2 more detailed example * log4j2 more detailed example * Improved names and examples * Fixed configurations * improved configs * formatted * Final fix * fixed formatting * Formatting fix * Fix sample apps to avoid try / catch * Fix request to replace files * Fix end lines * Log4j2 logger is shot down at the end. * Initial commit, the server starts launched from maven * made room for client and server projects * made room for client and server projects * base example works * poms restructured * packages restructured * packages restructured * Some renaming and a proper formatting string * Small renamings * Small renamings * Fixed invoked URL in client through fixing bean name * java.time.* instead of java.util.Date * java.time.* instead of java.util.Date * Removed log on file, kepts log on console * Updated Spring and Logback version to latest release. * Exception removed from run()
This commit is contained in:
committed by
KevinGilmore
parent
5cc5d7dc12
commit
5c99b291d5
+7
-6
@@ -5,22 +5,23 @@ import com.baeldung.api.Booking;
|
||||
import com.baeldung.api.BookingException;
|
||||
import com.baeldung.api.CabBookingService;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static java.lang.Math.random;
|
||||
import static java.lang.System.currentTimeMillis;
|
||||
import static java.time.LocalDateTime.now;
|
||||
import static java.time.temporal.ChronoUnit.MINUTES;
|
||||
import static java.util.UUID.randomUUID;
|
||||
|
||||
public class CabBookingServiceImpl implements CabBookingService {
|
||||
|
||||
@Override public Booking bookPickUp(Address pickUpLocation, Address dropOffLocation, int pax) throws BookingException {
|
||||
if(random()<0.3){
|
||||
if (random() < 0.3) {
|
||||
throw new BookingException("Cab unavailable");
|
||||
}
|
||||
int tripTimeInMinutes = (int) (5 + random() * 15);
|
||||
int costInCent = 15_00 + tripTimeInMinutes * 5 * pax;
|
||||
Date pickUpDate = new Date((long) (currentTimeMillis() + (1000 * 60 * random() * 15)));
|
||||
return new Booking(pickUpLocation, pickUpDate, dropOffLocation, costInCent, tripTimeInMinutes * 60,
|
||||
randomUUID().toString());
|
||||
LocalDateTime pickUpDate = now().plus(15L * (long) (random() * 10), MINUTES);
|
||||
|
||||
return new Booking(pickUpLocation, pickUpDate, dropOffLocation, costInCent, tripTimeInMinutes * 60, randomUUID().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,23 +5,12 @@
|
||||
value="%-30(%d{MMM dd YYYY HH:mm:ss.SSS} [%thread]) %-5level %logger{5} [%file:%line] - %msg%n"/>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- encoders are assigned the type
|
||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
|
||||
<encoder>
|
||||
<pattern>${logPattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>C:\Users\danidemi\tmp\baledung\app.log</file>
|
||||
<append>false</append>
|
||||
<encoder>
|
||||
<pattern>${logPattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user