Dev/guice-service1x

= Guice Service (prior to 1.4) =

 NB:  This is for releases of Guice Support prior to 1.4 only.

A Guice service works differently than games or tournaments. You need to create an implementation of your Contract which is not a Service. Then in you actual service implementation you wire up Guice to handle the former class and forward all method calls to it.


 * 1) Implement the contract using injections, but do not implement the 'Service' interface nor extend 'GuiceService'. This is your "clean room" implementation.
 * 2) Implement a service which extends GuiceService and implements you contract. This is the "proxy" which only job is to wire up your real implementation.
 * 3) Have Guice create your real implementation, and forward all method calls to it manually.

As you can see it's a bit more involved, and you need to remember:


 * You need two implementations of your contract: One which is a service and which do the Guice configuration, and one which is not a service in itself and is wired by Guice.

Quick How-To
Extend GuiceService, this is #2 from above:

public class MyService extends GuiceService implements MyServiceContract [...]

Override 'getConfigurationHelp' to return a configuraton, with your actual service implementation, from #1 above:

public Configuration getConfigurationHelp { return new Configuration {

public ContractsConfig getServiceContract { // Return the class of Guice wired "clean room" implementation }   }; }

Also, if you want to register your own modules, you can override 'preInjectorCreation':

public void preInjectorCreation(List list) { list.add(new MyServiceModule); }

On each service contract method, proxy call via Guice instance, which corresponds to #3 above:

public void myServiceMethod(Object...args) { guice(MyServiceContract.class).myServiceMethod(args); }

Special Injections
Any Firebase service can be injected (must be a service contract), via the special Service' injection annotation:

@Service private DatasourceServiceContract dsContract;

If a service is injected into another service during the initiation phase of the service life-cycle, the service must be proxied, otherwise the injection may result in a null value as the injected service may not be known:

@Service(proxy=true) private DatasourceServiceContract dsContract; You can also inject a Log4j logger anywhere using the special Log4j injection annotation:

@Log4j private Logger log;