2.5.2. Injection

There are two ways to inject a dependency:

Using a constructor:

public ServiceA(ServiceB serviceB)

Using setter methods:

public void setServiceB(ServiceB serviceB)

When a client service can not be stored in the container then the service locator pattern is used:

public ServiceA(){

   this.serviceB =Container.getSInstance().getService(ServiceB.class);
}
Copyright ©2012. All rights reserved. eXo Platform SAS