Questions tagged [robot-legs-problem]

The "robot legs" problem is about injecting custom configurations of reusable components

The "robot legs" problem is about injecting custom configurations of reusable components.

The "robot legs" problem describes the following scenario: How to create a robot with a two Leg objects, the left one injected with a LeftFoot, and the right one with a RightFoot. But only one Leg class that's reused in both contexts.

For more information, see: How do I build two similar but slightly different trees of objects?

9 questions
9
votes
1 answer

Generalize guice's robot-legs example with Multibinding

I have this use case that is very similar to the robot-legs example of Guice, except I don't know how many "legs" I have. Therefore I can't use the annotations needed for the robot-legs example. I expect to gather all these "legs" in an…
Olivier Grégoire
  • 33,839
  • 23
  • 96
  • 137
8
votes
1 answer

How can I use Scala's cake pattern to implement robot legs?

My development makes extensive use of the robot legs binding problem. I know how to solve it with PrivateModule in Guice, but it isn't clear how this would be done with Scala's cake pattern. Could someone explain how this would be done, ideally…
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
4
votes
3 answers

Can the Cake Pattern be used for non-singleton style dependencies?

Most of the examples of the Cake Pattern I've come across appear to consider dependencies as singleton type services; where there is only one instance of each type in the final assembly of components. Is it possible to write a configuration that has…
Kristian Domagala
  • 3,686
  • 20
  • 22
4
votes
3 answers

How do I bind Different Interfaces using Google Guice?

Do I need to create a new module with the Interface bound to a different implementation? Chef newChef = Guice.createInjector(Stage.DEVELOPMENT, new Module() { @Override public void configure(Binder binder) { …
unj2
  • 52,135
  • 87
  • 247
  • 375
2
votes
1 answer

Signal is never being injected - robotlegs2.0

In app config file I have a Signal/Command mapping signalCommandMap.map(DisconnectUserSignal).toCommand(DisconnectUserCommand); Then, I have two connection classes: public class BaseConnection implements IBaseConnection { // When I am trying to…
inside
  • 3,047
  • 10
  • 49
  • 75
1
vote
1 answer

guice: multiple implementations, different object graphs

How do you do the following in guice? There is class XmlSerializer that depends on an interface XmlFormatter. There are 2 implementations of XmlFormatter: CompactXmlFormatter and PrettyXmlFormatter. Another class MyApplication depends on 2 instances…
1
vote
3 answers

Guice: Building Related Trees of Objects / Robot Legs

I have a class A that holds a class B like this: class A { private final B b; @Inject A(B b) { this.b = b; } } interface B {} class B1 implements B {} class B2 implements B {} class Client() { @Inject Client(@AhasB1 A…
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
1
vote
0 answers

Robotlegs 2 migration - Dynamic view

I used RB1 in my projects the following way: I had externally-loaded GFX with linkage names. I did something like this: injector.mapClass(MyView, MyView); var ClassReference : Class = getDefinitionByName(id) as…
0
votes
1 answer

Are ambiguous robot legs valid?

In the Guice FAQ, they talk about differentiating multiple instances with annotations (kind of). My question: Can I bind a Impl to an Interface without an annotation, and bind another Impl to that same Interface with an annotation? Basically my…
Snekse
  • 15,474
  • 10
  • 62
  • 77