Does sponge have api for patterns like inversion of controll/depency injection?
Basically i would like to have something similar to beans in ejb (@Component
and @Autowired
).
Couldn’t you just shade your dependency in your plugin jar?
net.yourname.yourplugin.lib.randomlib
Not sure what do you mean, its not about library dependencies
Im talking about desingn patterns for singletons. Following code you can write in eg.: spring framework
@Repository //This class is a bean/singleton, you dont have to initialize it anywhere spring do all the work, its constructor must be without parameters
public void MyDao {
void mymethod();
}
@Service //another bean/singleton
public void MyService {
@Autowired
private MyDao dao; //When this class is loaded by a spring classloader value of this field is set to corrent object, you dont have to create static instance in mydao class call for example MyDao.getInstance.
}
thats pretty ugly sollution.
I am pretty sure singleton is an anti-pattern.
And I still can’t follow actually . You will have to give a more in-depth example in how this can be used with a sponge plugin.