AbstractMan
AbstractMan

Reputation: 253

Google GIN AbstractGinModule & GWT.Create()

I have a class that extends AbstractGinModule

like:

 public class ClientModule extends AbstractGinModule {

  public ClientModule() { }

 @Override   
  protected void configure() {
  ...
  ...   
  bind(...class).annotatedWith(...).to(...class).in(Singleton.class);
  ...
  }
 }

The idea that I have is to bind one class with another class based on a value stored in a property file.

like:

param contains the value coming from the property file

if(param.equals("instanceB"))
   bind(a.class).to(b.class)
else
   bind(a.class).to(c.class)

I have a class that access this property file and return a string with the value. This class is called: InstanceParameters.java

I would like to get an instance of this class within my ClientModule. But I don't find any way to do it. I tried with:

- InstanceParameters param = new InstanceParameters ();
- GWT.create(InstanceParameters.class); (Error because this method should only be used on the client side)

Is there a way to access this InstanceParameters class within this clientModule?

Thank you for your help

Upvotes: 4

Views: 1442

Answers (1)

Igor Klimer
Igor Klimer

Reputation: 15321

You don't need to read the file before launching the application - just before creating the AbstractGinModule (via GWT.create). So, load the Dictionary in your onModuleLoad method and pass the parameters, either as a whole InstanceParameters class or as the extracted String, via a provider or any other means.

Upvotes: 1

Related Questions