Skip to content

Injecting non artemis dependencies

Daan van Yperen edited this page May 30, 2019 · 3 revisions

Injecting non-artemis dependencies

@Wire also supports injecting of non-artemis objects. Note that you explicitly need to annotate these injection fields with @Wire.

by type

Sled sled = new Sled();
world world = new World(new WorldConfiguration()
     .register(sled));
public class MySystem extends BaseSystem
{
    @Wire
    protected Sled sled;
}

by name

world world = new World(new WorldConfiguration()
     .register("sled",myObject)
     .register("santaName","Phillip")
     .register("sledName","Turbo-5000")
     .setSystem(MyManager.class));
public class MyManager extends Manager
{
    @Wire(name="sled")
    protected Sled sled;

    @Wire(name="santaName")
    protected String santa;

    @Wire(name="sledName")
    protected String sled;    
}
Clone this wiki locally