Take the 2-minute tour ×

I have written several services that I am glueing together using Guice. For example some abstract service A is described by these interfaces


And the implementation is defined as


Would it be better to bind all of the above implementations to their interface in the service's module, or just the Service class itself?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

When you seperate contract (interface) and implementation (service-impl), you usually hand only the interfaces (api-jar) to the application-clients. So they will never see (and care about) any implementing beans.

Thus, in your client code, bind the interfaces:

public Service lookup() {
   return .... whatever you need to do to access the Service
share|improve this answer
add comment

Your Answer


