Question

I am in a situation where someone might be already in. I am using GWTP in my application. GWTP is using GIN as a client side dependency injection. GWTP also uses Dispatcher mechanism for sending request to server side.

Now, There are some classes (PRESENTERS) which is injected by GWTP, I have some other classes which are created runtime without injection that means using "new" keywork. Let's have an example :

// Injected
class Dispatcher {
}

// Injected
Class A {
    @Inject // I can do this and access the disp without any hurdle.
    Dispatcher disp;
}

// Created using "new" keywork 
class B {
    //@Inject I can't do this because of B is not an injected class. Correct me if I am wrong here 
    Dispatcher disp;
}

So, I need to access Injected class in non injected classes. You might think I havn't tried GWT.Create(Injector.class) method. I have tried that and I am able to get that object in non inected classes but the object Dispatcher is something different it increments(adds) "/dispatch/" to its base url. That means i need to have the same object which GWTP internally using. And GWTP creates the GIN INJECTOR at the entry point.

One solution is to put the same GIN INJECTOR to client side session (Static Hashmap) and use it in non injected classes (I have also tried this solution and it is working like charm).

I need more perfect solution which can work.

Thank you in advance.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top