Skip to content

Commit

Permalink
Beta test Jetty 12
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol authored and nicol committed Dec 15, 2024
1 parent b9c958a commit beadcd6
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 32 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
<dependency>
<groupId>org.zoomba-lang</groupId>
<artifactId>spark-core</artifactId>
<version>3.0</version>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/org/beta/TestJetty.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.beta;

import static spark.Spark.get;

public class TestJetty {

public static void main(String[] args) {

// port(8080);

get("/hello/:id", (request, response) -> {
System.out.println(request.pathInfo());
System.out.println(request.matchedPath());
System.out.println(request.queryString());
System.out.println(request.servletPath());

return "hello";
});



}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import javax.swing.Icon;

import org.apache.commons.lang3.ArrayUtils;
import org.eclipse.jetty.ee10.servlet.DefaultServlet;
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
import org.eclipse.jetty.ee10.servlet.ServletHolder;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.HttpConfiguration;
Expand All @@ -18,9 +21,6 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.Jetty;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.magic.api.beans.technical.MTGProperty;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/magic/servers/impl/HawtIOServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.io.IOException;
import java.util.Map;

import org.eclipse.jetty.ee10.webapp.WebAppContext;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.webapp.WebAppContext;
import org.magic.api.beans.technical.MTGProperty;
import org.magic.api.interfaces.abstracts.AbstractMTGServer;
import org.magic.services.MTGConstants;
Expand Down Expand Up @@ -34,7 +34,7 @@ public void init()


server = new Server(getInt("PORT"));
var handlers = new HandlerCollection();
var handlers = new Handler.Sequence();
handlers.setServer(server);
server.setHandler(handlers);
try {
Expand Down
44 changes: 22 additions & 22 deletions src/main/java/org/magic/servers/impl/JSONHttpServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private JsonObject error(Request req, Response response, Exception msg, int code

var obj = new JsonObject();
obj.addProperty("method", req.requestMethod());
obj.addProperty("uri", req.pathInfo());
obj.addProperty("uri", req.servletPath());
obj.addProperty("code", code);
obj.addProperty("msg", msg.getMessage());
obj.add("stack", converter.toJsonElement(msg.getStackTrace()));
Expand All @@ -214,7 +214,7 @@ private JsonObject ok(Request req, Response response, Object msg) {

var obj = new JsonObject();
obj.addProperty("method", req.requestMethod());
obj.addProperty("uri", req.pathInfo());
obj.addProperty("uri", req.servletPath());
obj.addProperty("code", 200);
obj.addProperty("msg", converter.toJson(msg));

Expand Down Expand Up @@ -481,7 +481,7 @@ private void initGed()


get("/ged/:class/:id", URLTools.HEADER_JSON,(request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public JsonArray call() throws Exception {
var arr = new JsonArray();
Expand Down Expand Up @@ -515,7 +515,7 @@ private void initDashboards()


get("/dash/variations/card/:scryfallId", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public Object call() throws Exception {

Expand Down Expand Up @@ -600,7 +600,7 @@ private void initAlerts()
private void initDecks()
{
get("/decks/list", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public Object call() throws Exception {
var arr = new JsonArray();
Expand Down Expand Up @@ -745,7 +745,7 @@ private void initMetadata()
get("/metadata/git", URLTools.HEADER_JSON, (request, response) -> GithubUtils.inst().getReleases(), transformer);

get("/metadata/version", "text", (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public String call() throws Exception {
return new VersionChecker().getVersion();
Expand All @@ -762,7 +762,7 @@ private void initPricers()
}, transformer);

get("/prices/:scryfallId", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {

@Override
public List<MTGPrice> call() throws Exception {
Expand All @@ -784,7 +784,7 @@ public List<MTGPrice> call() throws Exception {
, transformer);

get("/prices/details/:provider/:scryfallId", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {

@Override
public List<MTGPrice> call() throws Exception {
Expand All @@ -795,7 +795,7 @@ public List<MTGPrice> call() throws Exception {
, transformer);

get("/partner/:scryfallId", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public List<MTGPrice> call() throws Exception {
MTGCard mc = getEnabledPlugin(MTGCardsProvider.class).getCardByScryfallId(request.params(SCRYFALL_ID));
Expand Down Expand Up @@ -923,7 +923,7 @@ private void initAdmin()
private void initSets()
{
get("/editions/list", URLTools.HEADER_JSON,(request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {

@Override
public List<MTGEdition> call() throws Exception {
Expand All @@ -938,7 +938,7 @@ public List<MTGEdition> call() throws Exception {


get("/editions/list/:colName", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {

@Override
public List<MTGEdition> call() throws Exception{
Expand Down Expand Up @@ -1003,7 +1003,7 @@ private void initAnnounces()
private void initSealed()
{
get("/sealed/list", URLTools.HEADER_JSON,(request, response) ->{
var data=(List<MTGSealedStock>)getCached(request.pathInfo(), new Callable<Object>() {
var data=(List<MTGSealedStock>)getCached(request.servletPath(), new Callable<Object>() {

@Override
public List<MTGSealedStock> call() throws Exception {
Expand All @@ -1021,7 +1021,7 @@ public List<MTGSealedStock> call() throws Exception {


get("/sealed/list/:collection", URLTools.HEADER_JSON,(request, response) -> {
var data = (List<MTGSealedStock>)getCached(request.pathInfo(), new Callable<Object>() {
var data = (List<MTGSealedStock>)getCached(request.servletPath(), new Callable<Object>() {

@Override
public List<MTGSealedStock> call() throws Exception {
Expand All @@ -1041,7 +1041,7 @@ public List<MTGSealedStock> call() throws Exception {


get("/sealed/list/:collection/:idSet", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public List<MTGSealedStock> call() throws Exception {
return getEnabledPlugin(MTGDao.class).listSealedStocks(new MTGCollection(request.params(COLLECTION)),new MTGEdition(request.params(ID_SET)));
Expand Down Expand Up @@ -1155,7 +1155,7 @@ private void initCards()


get("/cards/list/:col", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public List<MTGCard> call() throws Exception {
var col = new MTGCollection(request.params(":col"));
Expand All @@ -1165,7 +1165,7 @@ public List<MTGCard> call() throws Exception {
, transformer);

get("/cards/list/:col/:idEd", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public List<MTGCard> call() throws Exception {
var col = new MTGCollection(request.params(":col"));
Expand All @@ -1176,7 +1176,7 @@ public List<MTGCard> call() throws Exception {
, transformer);

get("/cards/:idSet/cards", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public List<MTGCard> call() throws Exception {
var ed = getEnabledPlugin(MTGCardsProvider.class).getSetById(request.params(ID_SET));
Expand Down Expand Up @@ -1243,7 +1243,7 @@ private void initStocks()
});

get("/stock/list", URLTools.HEADER_JSON,(request, response) ->{
var data = (List<MTGCardStock>) getCached(request.pathInfo(), new Callable<Object>() {
var data = (List<MTGCardStock>) getCached(request.servletPath(), new Callable<Object>() {
@Override
public Object call() throws Exception {
return getEnabledPlugin(MTGDao.class).listStocks();
Expand All @@ -1261,7 +1261,7 @@ public Object call() throws Exception {

get("/stock/list/:collection", URLTools.HEADER_JSON,(request, response) ->{

var data = (List<MTGCardStock>) getCached(request.pathInfo(), new Callable<Object>() {
var data = (List<MTGCardStock>) getCached(request.servletPath(), new Callable<Object>() {
@Override
public Object call() throws Exception {
return getEnabledPlugin(MTGDao.class).listStocks(List.of(new MTGCollection(request.params(COLLECTION))));
Expand Down Expand Up @@ -1291,7 +1291,7 @@ public Object call() throws Exception {


get("/stock/list/:collection/:idSet", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public List<MTGCardStock> call() throws Exception {
return getEnabledPlugin(MTGDao.class).listStocks(request.params(COLLECTION), request.params(ID_SET));
Expand Down Expand Up @@ -1346,7 +1346,7 @@ private void initExtShop()


get("/extShop/list/stock/:provider", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {
@Override
public Object call() throws Exception {
return getPlugin(request.params(PROVIDER),MTGExternalShop.class).listStock("");
Expand Down Expand Up @@ -1435,7 +1435,7 @@ private void initWebShop()
{

get("/webshop/config", URLTools.HEADER_JSON, (request, response) ->
getCached(request.pathInfo(), new Callable<Object>() {
getCached(request.servletPath(), new Callable<Object>() {

@Override
public Object call() throws Exception {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/magic/servers/impl/ShoppingServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import javax.swing.Icon;

import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.ee10.servlet.DefaultServlet;
import org.eclipse.jetty.ee10.servlet.ServletHolder;
import org.magic.api.interfaces.abstracts.extra.AbstractWebServer;
import org.magic.services.MTGConstants;
import org.magic.services.MTGControler;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/data/default-shop.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},

"delivery": {
"shippingRules": "var shippingCost=0;\nif(total >=65)\n{ \n shippingCost = 0;\n}\nelse if(total >=25);\n{ \n shippingCost = 15;\n}else if(total&gt;=1);\n{ \n\tshippingCost = 6.50;\n}\n\nshippingCost;",
"shippingRules": "var shippingCost\u003d0;\nif(total \u003e\u003d65)\n{ \n shippingCost \u003d 0\n}\n\nif(total \u003e\u003d25)\n{ \n shippingCost \u003d 15;\n}\n\nif(total\u003e\u003d1)\n{ \n\tshippingCost \u003d 6.50;\n}\n\nshippingCost;",
"deliveryDay": 2
},

Expand Down

0 comments on commit beadcd6

Please sign in to comment.