{"id":15138545,"url":"https://github.com/yale8848/summer","last_synced_at":"2025-10-23T15:30:26.463Z","repository":{"id":57742622,"uuid":"119676507","full_name":"yale8848/Summer","owner":"yale8848","description":"Vertx router with JAX-RS","archived":false,"fork":false,"pushed_at":"2018-12-26T11:05:57.000Z","size":84,"stargazers_count":64,"open_issues_count":1,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-30T19:08:01.984Z","etag":null,"topics":["asynchronous","jax-rs","reactor","router","vertx","vertx-router","vertx-web"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yale8848.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-31T11:08:07.000Z","updated_at":"2023-03-21T01:59:24.000Z","dependencies_parsed_at":"2022-09-09T10:10:59.236Z","dependency_job_id":null,"html_url":"https://github.com/yale8848/Summer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yale8848%2FSummer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yale8848%2FSummer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yale8848%2FSummer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yale8848%2FSummer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yale8848","download_url":"https://codeload.github.com/yale8848/Summer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237843817,"owners_count":19375208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asynchronous","jax-rs","reactor","router","vertx","vertx-router","vertx-web"],"created_at":"2024-09-26T07:41:02.226Z","updated_at":"2025-10-23T15:30:26.038Z","avatar_url":"https://github.com/yale8848.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Summer\n\nVertx router with JAX-RS\n\n## Add to pom\n\n ```xml\n\n\u003cdependency\u003e\n  \u003cgroupId\u003eren.yale.java\u003c/groupId\u003e\n  \u003cartifactId\u003esummer\u003c/artifactId\u003e\n  \u003cversion\u003e1.1.9\u003c/version\u003e\n\u003c/dependency\u003e\n\n```\n\n\u003e wrapper io.vertx.vertx-core:3.5.4\n\n## How to use\n\nUse SummerRouter:\n\n```java\n\n  public class WebServer extends AbstractVerticle {\n\n   @Override\n   public void start() throws Exception {\n        Router router = Router.router(vertx);\n        SummerRouter summerRouter =  new SummerRouter(router,vertx);\n        summerRouter.registerResource(Hello.class);\n        vertx.createHttpServer()\n             .requestHandler(router::accept)\n                 .listen(port,host,httpServerAsyncResult -\u003e {\n                      if (httpServerAsyncResult.succeeded()){\n                            System.out.println(\"listen at: http://\"+host+\":\"+port);\n                      }else{\n                            System.out.println(httpServerAsyncResult.cause().getCause());\n                      }\n                    });\n        }\n    }\n```\n\nUse simple SummerServer(use io.vertx.core.AbstractVerticle):\n\n```java\n\n  SummerServer summerServer =SummerServer.create(8080);\n\n  summerServer.getSummerRouter().registerResource(Hello.class);\n\n  summerServer.start();\n\n```\nor further:\n\n```java\n\n   VertxOptions options = new VertxOptions();\n   options.setBlockedThreadCheckInterval(20000);\n   options.setMaxEventLoopExecuteTime(20000);\n   \n   SummerServer summerServer =SummerServer.create(\"localhost\",8080,options);\n\n   summerServer.getVertx().\n                deployVerticle(MyVerticle.class.getName());\n   \n   summerServer.getSummerRouter().registerResource(Hello.class);\n    \n   DeploymentOptions deploymentOptions = new DeploymentOptions();\n   deploymentOptions.setWorker(true);\n   summerServer.start(deploymentOptions);\n\n\n```\n\n\nHello.java with JAX-RS\n\n```java\n\n@Path(\"/hello\")\n@Before(LogInterceptor.class)\npublic class Hello {\n\n    @GET\n    @Path(\"/html/{name}\")\n    @Produces({MediaType.TEXT_HTML})\n    public String h1(@Context RoutingContext routingContext,\n                     @PathParam(\"name\") String name,\n                     @DefaultValue(\"18\") @QueryParam(\"age\") int age, String text){\n        return String.format(\"\u003chtml\u003e\u003cbody\u003ename:%s,age:%d\u003c/body\u003e\u003c/html\u003e\",name,age);\n    }\n\n    @POST\n    @Path(\"/name/bob\")\n    @Produces({MediaType.APPLICATION_JSON})\n    public User h2(@QueryParam(\"age\") int age,@FormParam(\"name\") String name) {\n        User u = new User();\n        u.setName(name);\n        u.setAge(age);\n        return u;\n    }\n\n    @GET\n    @Path(\"/async\")\n    public void h3(@Context HttpServerResponse response, @Context Vertx vertx){\n\n        vertx.eventBus().send(\"user\",EventMessage.message(\"bob\").setKey(\"name\"),message-\u003e{\n            EventMessage eventMessage = (EventMessage) message.result().body();\n           if (eventMessage.isSuccess()){\n               String ret= String.format(\"name:%s,age:%d\",eventMessage.getMessage(),18);\n               response.end(ret);\n          }else{\n               response.end(\"error\");\n           }\n        });\n\n    }\n\n    @GET\n    @Path(\"/xml\")\n    @Produces({MediaType.TEXT_XML})\n    public User xml(){\n        return new User();\n    }\n\n    @GET\n    @Path(\"/aop\")\n    @Produces({MediaType.APPLICATION_JSON})\n    @After(ChangeUserInterceptor.class)\n    public User getInter(){\n        User u = new User();\n        u.setName(\"bob\");\n        u.setAge(18);\n        return u;\n    }\n   \n    @HEAD\n    @Path(\"/head\")\n    public void head(@Context RoutingContext routingContext){\n        routingContext.response().setStatusCode(200).end();\n    }\n    \n    @PUT\n    @Path(\"/put/bob/{age}\")\n    @Produces({MediaType.APPLICATION_JSON})\n    public User put(@Context RoutingContext routingContext,@PathParam(\"age\") int age){\n\n        User u = new User();\n        u.setName(\"bob\");\n        u.setAge(age);\n        return u;\n    }\n\n    @DELETE\n    @Path(\"/delete/{name}\")\n    public String delete(@Context RoutingContext routingContext, @PathParam(\"name\") String name){\n        return \"delete \"+name+\" success\";\n    }\n}\n\n```\n\n## Add resource\n\nLike Hello.java, you can create your own resource and then call `summerServer.getSummerRouter().registerResource(Hello.class);`\n\n## AOP\n\n- Create a intercepter implements Interceptor. @After interceptor only work in sync mode\n\n```java\n\npublic class LogInterceptor implements Interceptor {\n    @Override\n    public boolean handle(RoutingContext routingContext, Object obj) {\n        System.out.println(routingContext.request().absoluteURI());\n        return false;\n    }\n}\n\npublic class ChangeUserInterceptor implements Interceptor {\n    @Override\n    public boolean handle(RoutingContext routingContext,Object obj) {\n        User user = (User) obj;\n        user.setName(\"Alice\");\n        routingContext.response()\n                .end(JsonObject.mapFrom(user).encodePrettily());\n        return true;\n    }\n}\n\n```\n`if handle return true will interrupt the chain, the method interceptor work before class interceptor`\n\n\n```java\n\n@Path(\"/hello\")\n@Before(LogInterceptor.class)\npublic class Hello {}\n\n@After(ChangeUserInterceptor.class)\npublic User getInter(){}\n\n```\n\n## Inject object \n\n```java\n\n\n    @GET\n    @Path(\"/test\")\n    public void test(@Context RoutingContext routingContext,\n                     @Context HttpServerRequest request,\n                     @Context HttpServerResponse response,\n                     @Context Session session,\n                     @Context Vertx vertx\n                       ){\n\n    }\n\n```\n\n## Return json\n\nBy default each method will return Object will return json;\n\n```java\n\n    @GET\n    @Path(\"/h2\")\n    public Test h2(){\n        return new Test();\n    }\n\n```\nthis will return Test json object\n\n## SQL builder\n\nSummerSQL [same as mybatis3 sqlbuilder](http://www.mybatis.org/mybatis-3/statement-builders.html)\n\n```java\n// With conditionals (note the final parameters, required for the anonymous inner class to access them)\npublic String selectPersonLike(final String id, final String firstName, final String lastName) {\n  return new SummerSQL() {{\n    SELECT(\"P.ID, P.USERNAME, P.PASSWORD, P.FIRST_NAME, P.LAST_NAME\");\n    FROM(\"PERSON P\");\n    if (id != null) {\n      WHERE(\"P.ID like #{id}\");\n    }\n    if (firstName != null) {\n      WHERE(\"P.FIRST_NAME like #{firstName}\");\n    }\n    if (lastName != null) {\n      WHERE(\"P.LAST_NAME like #{lastName}\");\n    }\n    ORDER_BY(\"P.LAST_NAME\");\n  }}.toString();\n}\n\n\n```\n\n## SQL ResultMapper\n\n```java\n\n   sqlConnection.query(new SummerSQL().SELECT(\"*\")\n                                .FROM(\"db_test.tb_test\").toString(), resultSetAsyncResult -\u003e {\n                            if (resultSetAsyncResult.succeeded()){\n\n                               List\u003cDBTest\u003e tests =  ResultSetMapper.create().camelName()\n                                        .mapperList(resultSetAsyncResult.result(), DBTest.class);\n                            }\n                            sqlConnection.close();\n                 });\n\n\n```\n\n\n## License\n\n```\nMIT License\n\nCopyright (c) 2018 Yale\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyale8848%2Fsummer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyale8848%2Fsummer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyale8848%2Fsummer/lists"}