forked from ntut-ben/ezfit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
141 changed files
with
291 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> | ||
|
||
|
||
|
||
|
||
<wb-module deploy-name="git_ezfit-0.0.1-SNAPSHOT"> | ||
|
||
|
||
|
||
|
||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> | ||
|
||
|
||
|
||
|
||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> | ||
|
||
|
||
|
||
|
||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> | ||
|
||
|
||
|
||
|
||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> | ||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/> | ||
|
||
|
||
<property name="java-output-path" value="/ezfit/target/classes"/> | ||
|
||
<property name="context-root" value="git_ezfit"/> | ||
|
||
|
||
|
||
|
||
</wb-module> | ||
|
||
|
||
|
||
|
||
</project-modules> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package chat.component; | ||
|
||
public class CacheManager { | ||
|
||
public static void put(String cacheName, String string, String sessionId) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
public static boolean containsKey(String cacheName, String string) { | ||
// TODO Auto-generated method stub | ||
return false; | ||
} | ||
|
||
public static void remove(String cacheName, String string) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package chat.handler; | ||
|
||
public class CacheConstant { | ||
|
||
private CacheConstant() { | ||
} | ||
|
||
/** | ||
* websocket用戶accountId | ||
*/ | ||
public static final String WEBSOCKET_ACCOUNT = "websocket_account"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package chat.handler; | ||
|
||
public class Constants { | ||
/** | ||
* SessionId | ||
*/ | ||
public static final String SESSIONID = "sessionid"; | ||
|
||
/** | ||
* Session對象Key, 用戶id | ||
*/ | ||
public static final String SKEY_ACCOUNT_ID = "accountId"; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/chat/handler/HttpSessionIdHandshakeInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package chat.handler; | ||
|
||
import java.util.Map; | ||
import javax.servlet.http.HttpSession; | ||
import org.springframework.http.server.ServerHttpRequest; | ||
import org.springframework.http.server.ServerHttpResponse; | ||
import org.springframework.http.server.ServletServerHttpRequest; | ||
import org.springframework.web.socket.WebSocketHandler; | ||
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; | ||
|
||
|
||
public class HttpSessionIdHandshakeInterceptor extends HttpSessionHandshakeInterceptor { | ||
@Override | ||
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, | ||
Map<String, Object> attributes) throws Exception { | ||
// 解決The extension [x-webkit-deflate-frame] is not supported問題 | ||
if (request.getHeaders().containsKey("Sec-WebSocket-Extensions")) { | ||
request.getHeaders().set("Sec-WebSocket-Extensions", "permessage-deflate"); | ||
} | ||
// 檢查session的值是否存在 | ||
if (request instanceof ServletServerHttpRequest) { | ||
ServletServerHttpRequest servletRequest = (ServletServerHttpRequest) request; | ||
HttpSession session = servletRequest.getServletRequest().getSession(false); | ||
String accountId = (String) session.getAttribute(Constants.SKEY_ACCOUNT_ID); | ||
// 把session和accountId存放起來 | ||
attributes.put(Constants.SESSIONID, session.getId()); | ||
attributes.put(Constants.SKEY_ACCOUNT_ID, accountId); | ||
} | ||
return super.beforeHandshake(request, response, wsHandler, attributes); | ||
} | ||
|
||
@Override | ||
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, | ||
Exception ex) { | ||
super.afterHandshake(request, response, wsHandler, ex); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/chat/handler/PresenceChannelInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package chat.handler; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.messaging.Message; | ||
import org.springframework.messaging.MessageChannel; | ||
import org.springframework.messaging.simp.stomp.StompHeaderAccessor; | ||
import org.springframework.messaging.support.ChannelInterceptor; | ||
|
||
import chat.component.CacheManager; | ||
|
||
public class PresenceChannelInterceptor implements ChannelInterceptor { | ||
private static final Logger logger = LoggerFactory.getLogger(PresenceChannelInterceptor.class); | ||
|
||
@Override | ||
public void postSend(Message<?> message, MessageChannel channel, boolean sent) { | ||
StompHeaderAccessor sha = StompHeaderAccessor.wrap(message); | ||
// ignore non-STOMP messages like heartbeat messages | ||
if (sha.getCommand() == null) { | ||
return; | ||
} | ||
// 這裏的sessionId和accountId對應HttpSessionIdHandshakeInterceptor攔截器的存放key | ||
String sessionId = sha.getSessionAttributes().get(Constants.SESSIONID).toString(); | ||
String accountId = sha.getSessionAttributes().get(Constants.SKEY_ACCOUNT_ID).toString(); | ||
// 判斷客戶端的連接狀態 | ||
switch (sha.getCommand()) { | ||
case CONNECT: | ||
connect(sessionId, accountId); | ||
break; | ||
case CONNECTED: | ||
break; | ||
case DISCONNECT: | ||
disconnect(sessionId, accountId, sha); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
// 連接成功 | ||
private void connect(String sessionId, String accountId) { | ||
logger.debug(" STOMP Connect [sessionId: " + sessionId + "]"); | ||
// 存放至ehcache | ||
String cacheName = CacheConstant.WEBSOCKET_ACCOUNT; | ||
// 若在多個瀏覽器登錄,直接覆蓋保存 | ||
CacheManager.put(cacheName, cacheName + accountId, sessionId); | ||
} | ||
|
||
// 斷開連接 | ||
private void disconnect(String sessionId, String accountId, StompHeaderAccessor sha) { | ||
logger.debug("STOMP Disconnect [sessionId: " + sessionId + "]"); | ||
sha.getSessionAttributes().remove(Constants.SESSIONID); | ||
sha.getSessionAttributes().remove(Constants.SKEY_ACCOUNT_ID); | ||
// ehcache移除 | ||
String cacheName = CacheConstant.WEBSOCKET_ACCOUNT; | ||
if (CacheManager.containsKey(cacheName, cacheName + accountId)) { | ||
CacheManager.remove(cacheName, cacheName + accountId); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.messaging.simp.config.ChannelRegistration; | ||
import org.springframework.messaging.simp.config.MessageBrokerRegistry; | ||
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; | ||
import org.springframework.web.socket.config.annotation.StompEndpointRegistry; | ||
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; | ||
import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration; | ||
|
||
import chat.handler.HttpSessionIdHandshakeInterceptor; | ||
|
||
@Configuration | ||
@EnableWebSocketMessageBroker | ||
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { | ||
|
||
/** | ||
* 服務器要監聽的端口,message會從這裏進來,要對這裏加一個Handler 這樣在網頁中就可以通過websocket連接上服務了 | ||
*/ | ||
@Override | ||
public void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) { | ||
// 註冊stomp的節點,映射到指定的url,並指定使用sockjs協議 | ||
stompEndpointRegistry.addEndpoint("/contactChatSocket").withSockJS() | ||
.setInterceptors(httpSessionIdHandshakeInterceptor()); | ||
; | ||
} | ||
|
||
// 配置消息代理 | ||
@Override | ||
public void configureMessageBroker(MessageBrokerRegistry registry) { | ||
// queue、topic、user代理 | ||
registry.enableSimpleBroker("/queue", "/topic", "/user"); | ||
registry.setUserDestinationPrefix("/user/"); | ||
} | ||
|
||
/** | ||
* 消息傳輸參數配置 | ||
*/ | ||
@Override | ||
public void configureWebSocketTransport(WebSocketTransportRegistration registry) { | ||
registry.setMessageSizeLimit(8192) // 設置消息字節數大小 | ||
.setSendBufferSizeLimit(8192)// 設置消息緩存大小 | ||
.setSendTimeLimit(10000); // 設置消息發送時間限制毫秒 | ||
} | ||
|
||
/** | ||
* 輸入通道參數設置 | ||
*/ | ||
@Override | ||
public void configureClientInboundChannel(ChannelRegistration registration) { | ||
registration.taskExecutor().corePoolSize(4) // 設置消息輸入通道的線程池線程數 | ||
.maxPoolSize(8)// 最大線程數 | ||
.keepAliveSeconds(60);// 線程活動時間 | ||
registration.interceptors(presenceChannelInterceptor()); | ||
} | ||
|
||
/** | ||
* 輸出通道參數設置 | ||
*/ | ||
@Override | ||
public void configureClientOutboundChannel(ChannelRegistration registration) { | ||
registration.taskExecutor().corePoolSize(4).maxPoolSize(8); | ||
registration.interceptors(presenceChannelInterceptor()); | ||
} | ||
|
||
@Bean | ||
public HttpSessionIdHandshakeInterceptor httpSessionIdHandshakeInterceptor() { | ||
return new HttpSessionIdHandshakeInterceptor(); | ||
} | ||
|
||
@Bean | ||
public PresenceChannelInterceptor presenceChannelInterceptor() { | ||
return new PresenceChannelInterceptor(); | ||
} | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+137 Bytes
(100%)
target/classes/Recipe/repository/Impl/BoardDao_Impl.class
Binary file not shown.
Binary file modified
BIN
+122 Bytes
(100%)
target/classes/Recipe/repository/Impl/FollowedRecipeDao_Impl.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+74 Bytes
(100%)
target/classes/Recipe/repository/Impl/KeyWordDao_Impl.class
Binary file not shown.
Binary file modified
BIN
+151 Bytes
(100%)
target/classes/Recipe/repository/Impl/MateralDao_Impl.class
Binary file not shown.
Binary file modified
BIN
+140 Bytes
(100%)
target/classes/Recipe/repository/Impl/MethodDao_Impl.class
Binary file not shown.
Binary file modified
BIN
+248 Bytes
(100%)
target/classes/Recipe/repository/Impl/RecipeDao_Impl.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+170 Bytes
(120%)
target/classes/Recipe/service/FollowedRecipeService.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+156 Bytes
(100%)
target/classes/Recipe/service/Impl/BoardService_Impl.class
Binary file not shown.
Binary file modified
BIN
+137 Bytes
(100%)
target/classes/Recipe/service/Impl/FollowedRecipeService_Impl.class
Binary file not shown.
Binary file modified
BIN
+138 Bytes
(100%)
target/classes/Recipe/service/Impl/GoodService_Impl.class
Binary file not shown.
Binary file modified
BIN
+52 Bytes
(100%)
target/classes/Recipe/service/Impl/KeyWordService_Impl.class
Binary file not shown.
Binary file modified
BIN
+162 Bytes
(100%)
target/classes/Recipe/service/Impl/MateralService_Impl.class
Binary file not shown.
Binary file modified
BIN
+129 Bytes
(100%)
target/classes/Recipe/service/Impl/MethodService_Impl.class
Binary file not shown.
Binary file modified
BIN
+182 Bytes
(100%)
target/classes/Recipe/service/Impl/RecipeService_Impl.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+41 Bytes
(110%)
target/classes/_00/init/web/CreateSessionFactoryListener.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+34 Bytes
(100%)
target/classes/_00/utils/HibernateProxyTypeAdapter$1.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+100 Bytes
(100%)
target/classes/createAccount/repository/MemberDaoImpl.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+63 Bytes
(100%)
target/classes/createAccount/service/Impl/CodeServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+63 Bytes
(100%)
target/classes/createAccount/service/Impl/MemberServiceImpl.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+114 Bytes
(120%)
target/classes/shopping/repository/CuisineProductDao.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+140 Bytes
(110%)
target/classes/shopping/repository/IngredientProductDao.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+72 Bytes
(120%)
target/classes/shopping/repository/ProductCategoryDao.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+198 Bytes
(100%)
target/classes/shopping/repository/impl/CartItemDaoImpl.class
Binary file not shown.
Binary file modified
BIN
+74 Bytes
(100%)
target/classes/shopping/repository/impl/CuisineProductDaoImpl.class
Binary file not shown.
Binary file modified
BIN
+111 Bytes
(100%)
target/classes/shopping/repository/impl/GroupBuyDaoImpl.class
Binary file not shown.
Binary file modified
BIN
+104 Bytes
(100%)
target/classes/shopping/repository/impl/IngredientProductDaoImpl.class
Binary file not shown.
Binary file modified
BIN
+93 Bytes
(100%)
target/classes/shopping/repository/impl/OrderDaoImpl.class
Binary file not shown.
Binary file modified
BIN
+41 Bytes
(100%)
target/classes/shopping/repository/impl/OrderItemDaoImpl.class
Binary file not shown.
Binary file modified
BIN
+41 Bytes
(100%)
target/classes/shopping/repository/impl/PlaneItemDaoImpl.class
Binary file not shown.
Binary file modified
BIN
+41 Bytes
(100%)
target/classes/shopping/repository/impl/PlaneProductDaoImpl.class
Binary file not shown.
Binary file modified
BIN
+52 Bytes
(100%)
target/classes/shopping/repository/impl/ProductCategoryDaoImpl.class
Binary file not shown.
Binary file modified
BIN
+63 Bytes
(100%)
target/classes/shopping/repository/impl/ProductDaoImpl.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+114 Bytes
(120%)
target/classes/shopping/service/CuisineProductService.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+140 Bytes
(110%)
target/classes/shopping/service/IngredientProductService.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+72 Bytes
(120%)
target/classes/shopping/service/ProductCategoryService.class
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+199 Bytes
(100%)
target/classes/shopping/service/impl/CartItemServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+78 Bytes
(100%)
target/classes/shopping/service/impl/CuisineProductServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+111 Bytes
(110%)
target/classes/shopping/service/impl/GroupBuyServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+97 Bytes
(100%)
target/classes/shopping/service/impl/IngredientProductServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+41 Bytes
(100%)
target/classes/shopping/service/impl/OrderItemServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+93 Bytes
(100%)
target/classes/shopping/service/impl/OrderServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+41 Bytes
(100%)
target/classes/shopping/service/impl/PlaneItemServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+41 Bytes
(100%)
target/classes/shopping/service/impl/PlaneProductServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+52 Bytes
(100%)
target/classes/shopping/service/impl/ProductCategoryServiceImpl.class
Binary file not shown.
Binary file modified
BIN
+63 Bytes
(100%)
target/classes/shopping/service/impl/ProductServiceImpl.class
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
target/m2e-wtp/web-resources/META-INF/maven/ntut.edu.com.java012/git_ezfit/pom.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters