2014-12-04 83 views
1

不好意思!我在這裏有一個問題。哪個版本的Spring是「org.springframework.session。*」?我根本無法在Spring4.0 jar中找到它。 這裏是類:Spring4 session

public abstract class AbstractSessionWebSocketMessageBrokerConfigurer<S extends ExpiringSession> 
      extends AbstractWebSocketMessageBrokerConfigurer { 
    @Autowired 
    @SuppressWarnings("rawtypes") 
    private SessionRepository sessionRepository; 
    @Autowired 
    private ApplicationEventPublisher eventPublisher; 

    @Override 
    public void configureClientInboundChannel(ChannelRegistration registration) { 
     registration.setInterceptors(sessionRepositoryInterceptor()); 
    } 

    @Override 
    public final void registerStompEndpoints(StompEndpointRegistry registry) { 
     configureStompEndpoints(new SessionStompEndpointRegistry(registry,sessionRepositoryInterceptor())); 
    } 

    /** 
    * Register STOMP endpoints mapping each to a specific URL and (optionally) 
    * enabling and configuring SockJS fallback options with a 
    * {@link SessionRepositoryMessageInterceptor} automatically added as an 
    * interceptor. 
    * 
    * @param registry 
    *   the {@link StompEndpointRegistry} which automatically has a 
    *   {@link SessionRepositoryMessageInterceptor} added to it. 
    */ 
    protected abstract void configureStompEndpoints(StompEndpointRegistry registry); 

    @Override 
    public void configureWebSocketTransport(
      WebSocketTransportRegistration registration) { 
     registration.addDecoratorFactory(wsConnectHandlerDecoratorFactory()); 
    } 

    @Bean 
    public WebSocketRegistryListener webSocketRegistryListener() { 
     return new WebSocketRegistryListener(); 
    } 

    @Bean 
    public WebSocketConnectHandlerDecoratorFactory wsConnectHandlerDecoratorFactory() { 
     return new WebSocketConnectHandlerDecoratorFactory(eventPublisher); 
    } 

    @Bean 
    @SuppressWarnings("unchecked") 
    public SessionRepositoryMessageInterceptor<S> sessionRepositoryInterceptor() { 
     return new SessionRepositoryMessageInterceptor<S>(sessionRepository); 
    } 

    static class SessionStompEndpointRegistry implements StompEndpointRegistry { 
     private final StompEndpointRegistry registry; 
     private final HandshakeInterceptor interceptor; 

     public SessionStompEndpointRegistry(StompEndpointRegistry registry,HandshakeInterceptor interceptor) { 
      this.registry = registry; 
      this.interceptor = interceptor; 
     } 

     public StompWebSocketEndpointRegistration addEndpoint(String... paths) { 
      StompWebSocketEndpointRegistration endpoints = registry.addEndpoint(paths); 
      endpoints.addInterceptors(interceptor); 
      return endpoints; 
     } 
    } 
} 

回答

0

春季會議是一個單獨的項目:https://github.com/spring-projects/spring-session

您應該使用一些依賴管理工具(Gradle或Maven)來控制應用程序的工件。

請參閱WebScoket示例:https://github.com/spring-projects/spring-session/tree/master/samples/websocket

一個春季會議神器:

compile "org.springframework.session:spring-session:1.0.0.RC1" 
+0

,因爲這是目前一個孵化項目,還應該配置Maven/gradle這個使用這個神器庫:https://repo.spring.io/libs -milestone/ – 2014-12-05 08:47:02

+0

謝謝Artem Bilan,我真的很感激! – Olivia 2014-12-09 07:04:21

+0

很高興聽到!如果答案是可以接受的,你應該以適當的方式標記。 – 2014-12-09 08:09:13