Dropwizard - organizing your project, understanding terminology, etc

Sun picture Sun · Apr 12, 2013 · Viewed 10.2k times · Source

I am learning to use Dropwizard. I was able to follow the quickstart guide and run basic REST APIs.

In this documentation, there is a section called "Organizing your project".

It recommends to organize your project in following parts: project-api, project-client, project-service.

Here are my questions/queries:

  1. Please explain, in general terms, the difference between 'api', 'service' and 'client'.

  2. Is there an example which strictly follows the above convention using dropwizard?

  3. "...project-client should use those classes and an HTTP client to implement a full-fledged client for your service" --- since 'project-service' will have the REST APIs, then why do we need to use HTTP Client?

Thanks!

Answer

Sandy T picture Sandy T · Apr 14, 2013
  1. Dropwizard recommends that you follow the below project structure:

    {project_name} (i.e parent with following modules)

    • {project_name}-api : should have all the value objects/POJO's that you are using in your project.
    • {project_name}-client : should contain client code used to get data from external rest service. Can be excluded, if you don't have any.
    • {project_name}-service : contains the remaining (service, configuration , resources, dao...etc).
  2. You may find this example helpful, even though client part is empty.

  3. As mentioned in the short description for client in point 1, if your project has any call to external rest services then related (HTTP)client code should go inside client module. Otherwise exclude the module itself.