2
donuts
6y

I need to write a standalone server in Java 1.7 and have it

-handle GET urls and map them to different classes/methods
-extract the query params and expose them to the method
-Can respond in JSON by serialising the POJO or a list of them

We have an existing server I think that uses JBoss but takes forever to start and uses a lot of memory.

I also wrote one before with just a (Grizzly?) HttpServer so had to manually implement the above as needed. Only needed it to do one thing so really just 1 path.

Similar situation this time but I'd prefer to not have to implement this stuff manually and need it to be a bit more flexible to extension.

Comments
  • 0
    What library/framework can I use?
  • 3
    Spring
  • 0
    @growling That's a coming framework? How does it start and configure a server?
  • 2
    You can use Spring Boot which uses embedded tomcat by default. You can also swap out tomcat for jetty if you like.
  • 0
    @stryter so I can like annotate the classes and methods so it gets the query params and and just return objects which it will serialize automatically?

    Guess will give it a try thanks.
  • 1
    Another framework would be Dropwizard, you can use annotations path resolving and for your parameters.
  • 1
    @billgates absolutely. You actually have a variety of ways to tackle the problem you are describing with Spring (Boot).

    I would highly recommend giving it a shot. You won't be disappointed :)
Add Comment