Additional Checkstyle Fixes

Issue gh-393
This commit is contained in:
Rob Winch
2016-03-07 15:32:03 -06:00
parent 7f3302253b
commit f0200696ef
189 changed files with 4591 additions and 3201 deletions

View File

@@ -23,8 +23,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Initializes the H2 {@link WebServlet} so we can access our in memory database
* from the URL "/h2".
* Initializes the H2 {@link WebServlet} so we can access our in memory database from the
* URL "/h2".
*
* @author Rob Winch
*/

View File

@@ -33,10 +33,9 @@ import org.springframework.session.data.redis.config.annotation.web.http.EnableR
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
// tag::enable-redis-httpsession[]
@EnableRedisHttpSession//(maxInactiveIntervalInSeconds = 60)
public class WebSecurityConfig
extends WebSecurityConfigurerAdapter {
// end::enable-redis-httpsession[]
@EnableRedisHttpSession // (maxInactiveIntervalInSeconds = 60)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
// end::enable-redis-httpsession[]
// @formatter:off
@Override

View File

@@ -32,8 +32,7 @@ public class WebSocketConfig
extends AbstractSessionWebSocketMessageBrokerConfigurer<ExpiringSession> { // <1>
protected void configureStompEndpoints(StompEndpointRegistry registry) { // <2>
registry.addEndpoint("/messages")
.withSockJS();
registry.addEndpoint("/messages").withSockJS();
}
public void configureMessageBroker(MessageBrokerRegistry registry) {

View File

@@ -24,8 +24,10 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.session.ExpiringSession;
/**
* These handlers are separated from WebSocketConfig because they are specific to this application and do not demonstrate a typical Spring Session setup.
* These handlers are separated from WebSocketConfig because they are specific to this
* application and do not demonstrate a typical Spring Session setup.
*
* @author Rob Winch
*/
@@ -33,12 +35,16 @@ import org.springframework.session.ExpiringSession;
public class WebSocketHandlersConfig<S extends ExpiringSession> {
@Bean
public WebSocketConnectHandler<S> webSocketConnectHandler(SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository repository) {
public WebSocketConnectHandler<S> webSocketConnectHandler(
SimpMessageSendingOperations messagingTemplate,
ActiveWebSocketUserRepository repository) {
return new WebSocketConnectHandler<S>(messagingTemplate, repository);
}
@Bean
public WebSocketDisconnectHandler<S> webSocketDisconnectHandler(SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository repository) {
public WebSocketDisconnectHandler<S> webSocketDisconnectHandler(
SimpMessageSendingOperations messagingTemplate,
ActiveWebSocketUserRepository repository) {
return new WebSocketDisconnectHandler<S>(messagingTemplate, repository);
}
}

View File

@@ -24,7 +24,8 @@ import org.springframework.security.config.annotation.web.socket.AbstractSecurit
* @author Rob Winch
*/
@Configuration
public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer {
public class WebSocketSecurityConfig
extends AbstractSecurityWebSocketMessageBrokerConfigurer {
// @formatter:off
@Override

View File

@@ -56,5 +56,4 @@ public class ActiveWebSocketUser {
this.connectionTime = connectionTime;
}
}

View File

@@ -21,7 +21,8 @@ import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
public interface ActiveWebSocketUserRepository extends CrudRepository<ActiveWebSocketUser, String> {
public interface ActiveWebSocketUserRepository
extends CrudRepository<ActiveWebSocketUser, String> {
@Query("select DISTINCT(u.username) from ActiveWebSocketUser u where u.username != ?#{principal?.username}")
List<String> findAllActiveUsers();

View File

@@ -59,6 +59,4 @@ public class InstantMessage {
this.created = created;
}
}

View File

@@ -44,7 +44,8 @@ public class MessageController {
private ActiveWebSocketUserRepository activeUserRepository;
@Autowired
public MessageController(ActiveWebSocketUserRepository activeUserRepository, SimpMessageSendingOperations messagingTemplate) {
public MessageController(ActiveWebSocketUserRepository activeUserRepository,
SimpMessageSendingOperations messagingTemplate) {
this.activeUserRepository = activeUserRepository;
this.messagingTemplate = messagingTemplate;
}

View File

@@ -27,16 +27,14 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.context.SecurityContextHolder;
/**
* Annotate Spring MVC method arguments with this annotation to indicate you
* wish to specify the argument with the value of the current
* {@link Authentication#getPrincipal()} found on the
* {@link SecurityContextHolder}.
* Annotate Spring MVC method arguments with this annotation to indicate you wish to
* specify the argument with the value of the current
* {@link Authentication#getPrincipal()} found on the {@link SecurityContextHolder}.
*
* <p>
* Creating your own annotation that uses {@link AuthenticationPrincipal} as a
* meta annotation creates a layer of indirection between your code and Spring
* Security's. For simplicity, you could instead use the
* {@link AuthenticationPrincipal} directly.
* Creating your own annotation that uses {@link AuthenticationPrincipal} as a meta
* annotation creates a layer of indirection between your code and Spring Security's. For
* simplicity, you could instead use the {@link AuthenticationPrincipal} directly.
* </p>
*
* @author Rob Winch

View File

@@ -42,8 +42,12 @@ public class UserRepositoryUserDetailsService implements UserDetailsService {
this.userRepository = userRepository;
}
/* (non-Javadoc)
* @see org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername(java.lang.String)
/*
* (non-Javadoc)
*
* @see
* org.springframework.security.core.userdetails.UserDetailsService#loadUserByUsername
* (java.lang.String)
*/
public UserDetails loadUserByUsername(String username)
throws UsernameNotFoundException {

View File

@@ -29,11 +29,13 @@ import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.web.socket.messaging.SessionConnectEvent;
public class WebSocketConnectHandler<S> implements ApplicationListener<SessionConnectEvent> {
public class WebSocketConnectHandler<S>
implements ApplicationListener<SessionConnectEvent> {
private ActiveWebSocketUserRepository repository;
private SimpMessageSendingOperations messagingTemplate;
public WebSocketConnectHandler(SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository repository) {
public WebSocketConnectHandler(SimpMessageSendingOperations messagingTemplate,
ActiveWebSocketUserRepository repository) {
super();
this.messagingTemplate = messagingTemplate;
this.repository = repository;
@@ -46,7 +48,9 @@ public class WebSocketConnectHandler<S> implements ApplicationListener<SessionCo
return;
}
String id = SimpMessageHeaderAccessor.getSessionId(headers);
this.repository.save(new ActiveWebSocketUser(id, user.getName(), Calendar.getInstance()));
this.messagingTemplate.convertAndSend("/topic/friends/signin", Arrays.asList(user.getName()));
this.repository.save(
new ActiveWebSocketUser(id, user.getName(), Calendar.getInstance()));
this.messagingTemplate.convertAndSend("/topic/friends/signin",
Arrays.asList(user.getName()));
}
}

View File

@@ -25,11 +25,13 @@ import org.springframework.context.ApplicationListener;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
public class WebSocketDisconnectHandler<S> implements ApplicationListener<SessionDisconnectEvent> {
public class WebSocketDisconnectHandler<S>
implements ApplicationListener<SessionDisconnectEvent> {
private ActiveWebSocketUserRepository repository;
private SimpMessageSendingOperations messagingTemplate;
public WebSocketDisconnectHandler(SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository repository) {
public WebSocketDisconnectHandler(SimpMessageSendingOperations messagingTemplate,
ActiveWebSocketUserRepository repository) {
super();
this.messagingTemplate = messagingTemplate;
this.repository = repository;
@@ -46,7 +48,8 @@ public class WebSocketDisconnectHandler<S> implements ApplicationListener<Sessio
}
this.repository.delete(id);
this.messagingTemplate.convertAndSend("/topic/friends/signout", Arrays.asList(user.getUsername()));
this.messagingTemplate.convertAndSend("/topic/friends/signout",
Arrays.asList(user.getUsername()));
}
}