Inversion of controll and sponge

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?

The SpongeAPI uses Google Guice for dependency injection, if that’s what you’re looking for.

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 {
     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 :confused:. You will have to give a more in-depth example in how this can be used with a sponge plugin.

@thomas15v The singleton pattern is an actual design pattern ;).