-
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.
Migrate from standard socket to Netty for improved performance
- Loading branch information
1 parent
a106dea
commit a064adb
Showing
17 changed files
with
420 additions
and
543 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
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
23 changes: 23 additions & 0 deletions
23
src/main/java/tech/bingulhan/webserver/response/NettyResponseHandler.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,23 @@ | ||
package tech.bingulhan.webserver.response; | ||
|
||
public interface NettyResponseHandler { | ||
|
||
|
||
void handleResponse(NettyResponseService service, RequestStructure structure); | ||
|
||
static void handle(NettyResponseService service, RequestStructure structure) { | ||
String[] paths = structure.getRoot().split("/"); | ||
if (paths.length>1) { | ||
for (NettyResponseType type: NettyResponseType.values()) { | ||
if (type.path.equals(paths[1])) { | ||
type.handler.handleResponse(service, structure); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
NettyResponseType.PAGE.handler.handleResponse(service,structure); | ||
|
||
|
||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/tech/bingulhan/webserver/response/NettyResponseService.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,22 @@ | ||
package tech.bingulhan.webserver.response; | ||
|
||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.handler.codec.http.DefaultHttpRequest; | ||
import lombok.Getter; | ||
import tech.bingulhan.webserver.app.AureliusApplication; | ||
|
||
@Getter | ||
public class NettyResponseService { | ||
|
||
private DefaultHttpRequest request; | ||
|
||
private ChannelHandlerContext ctx; | ||
|
||
private AureliusApplication application; | ||
|
||
public NettyResponseService(AureliusApplication application, DefaultHttpRequest request, ChannelHandlerContext ctx) { | ||
this.application = application; | ||
this.request = request; | ||
this.ctx = ctx; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/tech/bingulhan/webserver/response/NettyResponseType.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,19 @@ | ||
package tech.bingulhan.webserver.response; | ||
|
||
import tech.bingulhan.webserver.response.impl.media.NettyResponseMediaHandler; | ||
import tech.bingulhan.webserver.response.impl.mvc.NettyResponseMvcHandler; | ||
|
||
public enum NettyResponseType { | ||
|
||
PAGE("", new NettyResponseMvcHandler()), | ||
MEDIA("public", new NettyResponseMediaHandler()); | ||
; | ||
public String path; | ||
|
||
public NettyResponseHandler handler; | ||
NettyResponseType(String path, NettyResponseHandler handler) { | ||
this.path = path; | ||
this.handler = handler; | ||
} | ||
|
||
} |
26 changes: 0 additions & 26 deletions
26
src/main/java/tech/bingulhan/webserver/response/ResponseHandler.java
This file was deleted.
Oops, something went wrong.
110 changes: 0 additions & 110 deletions
110
src/main/java/tech/bingulhan/webserver/response/ResponseService.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
src/main/java/tech/bingulhan/webserver/response/ResponseType.java
This file was deleted.
Oops, something went wrong.
71 changes: 0 additions & 71 deletions
71
src/main/java/tech/bingulhan/webserver/response/WebSocketResponse.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.