NoteService should be the only class with access to NoteDao; nowhere else should NoteDao be accessed directly. Channel dependencies are static in PacketProcessor, for now. Ideally they would be injected in the constructor, but since the constructor is private and I don't want to open up that can of worms, I'll leave it like this. At the very least, now we have a way of injecting services into the handlers. This will make further restructuring way easier.
13 lines
218 B
Java
13 lines
218 B
Java
package net;
|
|
|
|
import service.NoteService;
|
|
|
|
import java.util.Objects;
|
|
|
|
public record ChannelDependencies(NoteService noteService) {
|
|
|
|
public ChannelDependencies {
|
|
Objects.requireNonNull(noteService);
|
|
}
|
|
}
|