🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.java
3 messages
3 total messages Started by J-23 Fri, 13 Jun 2014 17:07
{JAVA} CachingDispatchAsync problem
#154025
Author: J-23
Date: Fri, 13 Jun 2014 17:07
82 lines
2978 bytes
Witam,
Mam klasÄ™ CachingDispatchAsync, mam biblioteki GWTDispatch, Gin, Guice

import java.util.HashMap;
import java.util.Map;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.inject.Inject;
import net.customware.gwt.dispatch.client.DispatchAsync;
import net.customware.gwt.dispatch.shared.Action;
import net.customware.gwt.dispatch.shared.Result;

/**
* Dispatcher which support caching of data in memory
*
*/
public class CachingDispatchAsync implements DispatchAsync {
  private DispatchAsync dispatcher;
  private Map, Result> cache = new HashMap, Result>(); - tutaj jakoĹ› to 
dziwnie skonstruowane (sypie błędami)

  @Inject
  public CachingDispatchAsync(final DispatchAsync dispatcher) {
   this.dispatcher = dispatcher;
  }

  /*
   * (non-Javadoc)
   * @see net.customware.gwt.dispatch.client.DispatchAsync#execute(A, 
com.google.gwt.user.client.rpc.AsyncCallback)
   */
  public , R extends Result> void execute(final A action, final 
AsyncCallback callback) { -- tutaj mnie zastanawia ten "," przed "R"
   dispatcher.execute(action, callback);
  }

  /**
   * Execute the give Action. If the Action was executed before it will 
get fetched from the cache
   *
   * @param Action implementation
   * @param Result implementation
   * @param action the action
   * @param callback the callback
   */
  @SuppressWarnings("unchecked")
  public , R extends Result> void executeWithCache(final A action, final 
AsyncCallback callback) {
   final Result r = cache.get(action);

   if (r != null) {
    callback.onSuccess((R) r);
   }
   else {
    dispatcher.execute(action, new AsyncCallback() {

     public void onFailure(Throwable caught) {
      callback.onFailure(caught);
     }

     public void onSuccess(R result) {
      cache.put((Action) action, (Result) result);
      callback.onSuccess(result);
     }

    });
   }
  }

  /**
   * Clear the cache
   */
  public void clear() {
   cache.clear();
  }
}


klasa pochodzi stÄ…d 
http://blog.hivedevelopment.co.uk/2009/08/google-web-toolkit-gwt-mvp-example.html 
jak ją poprawić by to poprawnie działało?

Pozdrawiam
Re: {JAVA} CachingDispatchAsync problem
#154026
Author: Arivald
Date: Fri, 13 Jun 2014 17:47
18 lines
1468 bytes
On 2014-06-13 19:07, J-23 wrote:
> Witam,
> Mam klasÄ™ CachingDispatchAsync, mam biblioteki GWTDispatch, Gin, Guice
[...]

> klasa pochodzi stÄ…d
> http://blog.hivedevelopment.co.uk/2009/08/google-web-toolkit-gwt-mvp-example.html
> jak ją poprawić by to poprawnie działało?
>
> Pozdrawiam


poszukać poprawnej wersji? np stąd:

https://code.google.com/p/teamscape/source/browse/TeamScape/src/se/teamscape/client/rpc/CachingDispatchAsync.java?r=e734be36df6c7f07345c52ed4de071c69be743ac

-- 
Arivald
Re: {JAVA} CachingDispatchAsync problem
#154027
Author: J-23
Date: Fri, 13 Jun 2014 18:05
23 lines
1569 bytes
W dniu 13.06.2014 19:47, Arivald pisze:
> On 2014-06-13 19:07, J-23 wrote:
>> Witam,
>> Mam klasÄ™ CachingDispatchAsync, mam biblioteki GWTDispatch, Gin, Guice
> [...]
>
>> klasa pochodzi stÄ…d
>> http://blog.hivedevelopment.co.uk/2009/08/google-web-toolkit-gwt-mvp-example.html
>>
>> jak ją poprawić by to poprawnie działało?
>>
>> Pozdrawiam
>
>
> poszukać poprawnej wersji? np stąd:
>
> https://code.google.com/p/teamscape/source/browse/TeamScape/src/se/teamscape/client/rpc/CachingDispatchAsync.java?r=e734be36df6c7f07345c52ed4de071c69be743ac
>
>

Szukałem ale to jakoś umknęło mojej uwadze, dziękuje

Pozdrawiam
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads