On 10-07-16 16:00, Jerem's wrote:
> Sorry for the long time to answer. I had not time to test it before.
> I am not sure that your solution is good for me. I don"t want to
> switch implementation. I want the many "services' use the same
> structure.
>
> I think I have finished to develop my structure: this is my module :
>
> [CODE]
> @Override
> protected void configure() {
>
> bind(ISImpleGraphFactory.class).to(SimpleGraphFactoryImpl.class).in(Singleton.class);
> bind(ISimpleGraph.class).to(SimpleGraphImpl.class);
> bind(ISimpleNode.class).to(SimpleNodeImpl.class);
> bind(ISimpleEdge.class).to(SimpleEdgeImpl.class);
> }
> [/CODE]
>
> I use a factory only to create edge (because edge need instance of 2
> nodes).
For me this makes no sense. Do you really want to ask Guice for each
single Node? Imagine each Node is immutable (as it should be if
possible) and contains its name. How do you plan to make Guice know
what's the name of the new Node?
I'm quite sure you're going to make your life harder this way. Simply
asking Guice for NodeFactory, EdgeFactory, and GraphFactory would IMHO
do all you need.
> now I would like to create a service. A simple service called
> DemoService. this service create juste a simple graph.
> this service is implemented in an other maven project.
> How can I make work together the module of graphStructure project and
> the module of the demoProject ?
> I would like to limits the dependances between these two project.
Don't let the dependent project know the implementations, let it see the
interfaces only (extract them to a third project).
> And I have read the we should not use too much this line :
>
> Injector injector = Guice.createInjector(new
> SimpleGraphStructureModule());
>
> What is the guice good way to do that?
Ideally, you should create only one injector and ask it for only one
object, which provides the root service you need. However, the world is
not ideal, so you may need child injectors, passing injectors around, or
whatever. That said, I'm not sure if I understood your question.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.