I am trying to do the following. If possible I want to avoid creating them using the 'new' keyword, and rely on Dependency Injection. Is this possible given the following scenario?
public class One {
@Inject
private Two two;
@PostConstruct
public void createComposite(final Composite parent) {
final Composite container = doSomethingWithParent(parent);
// How do I call Twos constructor using injection and pass it the value for container?
// new Two(context, container);
}
}
@Creatable
@Singleton
public class Two
@Inject
public Two(final IEclipseContext context, final Composite containerFromOne) {
context.set(Two.class.getName(), this);
doSomethingImportantThatNeedsComposite(containerFromOne);
}
}
public class Three
@Inject
private Two two;
// I would like be able to use two anywhere in this class
// once two is instantiated by One
}
I was also looking at the ContextInjectionFactory.make() but I don't see a way to pass in constructor arguments.