java - Using Guice, inject dependency in child class -


I want to inject the dependence in a parent class using the hair class using the movement. In the example below, I am trying to make an example of TrainingCommandData , whereas I want to sign in TelemetryServiceClient using Guice during Wrighttime. How can I do this?

  Public class training edit data data command {intention of personal intention; Public Training Commendata (User Resource User Commodity Resources, Antient Content) {Super (user commerce server); This.intent = intention; }} Public Class Command Data {Private Telemetry Service Service Telemetry Service Customer; Private user commandsur user commerce resources; @ Public Set Set Set Telemetry Service Customer (Telemetry Service Client Telemetry Service Service) {this.telemetryServiceClient = telemetryServiceClient; } Public command data (user commandsur user commerce) {this.userCommandResource = userCommandResource; When you increase a square, the driver's injection of the parent when you increase a square.}}  

Depending on the dependence for you, you simply make Guice an example of the commands of training for you and you automatically receive telemetry service service injection.

There are some issues with the above code:

  1. Enter "@ inject" on your non-default constructor ... and certainly able to create all parameters for you Should be If you only keep these parameters in runtime, take a look at the assisted injection extension
  2. Use of injection injection is not a good option for your use ... why to give your command data suggestion possible Is a new example of service at runtime? I do not provide the set, but the field does not use injection, or, if you do not do so, the injection injection.

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -