CanDI Pattern Tutorial: GetServlet

GetServlet retrieves the service pattern, demonstrating that the service is shared between all injecting classes

Demo Links

CanDI Service Pattern

BindingValue
@Inject MyServiceMyServiceBean[MyStartupBean: initial value]

CanDI Plugin/Extension Pattern

  1. BlueResourceBean[blue resource]
  2. GreenResourceBean[default]
  3. RedResourceBean[red resource]
  4. StartupResourceBean[MyStartupBean: initial value]

CanDI Startup Pattern

BindingValue
@Inject StartupResourceBeanStartupResourceBean[MyStartupBean: initial value]

Demo Architecture

Code

public class GetServlet extends HttpServlet {
  // service pattern
  private @Inject MyService _service;

  // plugin/extension pattern
  private @Any Instance<MyResource> _resources;

  // startup pattern
  private @Inject StartupResourceBean _startupResource;

  ...
}