Annotation Interface Inject
Indicates that a field or constructor should be automatically injected by the
ServiceRegistry.
Fields: If the field type is JavaPlugin or a subclass, the plugin instance is injected.
If it is Logger, the plugin's logger is injected.
Otherwise, the field is resolved as a service from the registry.
Constructors: Marks the constructor the registry should use to create the instance. Each parameter is resolved the same way as an injected field. At most one constructor per class may be annotated. If a class has no annotated constructor, the registry falls back to a constructor taking only the plugin, then a no-argument constructor, and finally to the single declared constructor if there is exactly one.
@Service
public class StatsService {
private final Storage storage;
@Inject
public StatsService(Storage storage) {
this.storage = storage;
}
}