import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import com.vaadin.event.EventRouter;
private ErrorHandler errorHandler = null;
+ private static final ConcurrentHashMap<Class<? extends AbstractClientConnector>, Class<? extends SharedState>> stateTypeCache = new ConcurrentHashMap<Class<? extends AbstractClientConnector>, Class<? extends SharedState>>();
+
@Override
public void addAttachListener(AttachListener listener) {
addListener(AttachEvent.ATTACH_EVENT_IDENTIFIER, AttachEvent.class,
// Lazy load because finding type can be expensive because of the
// exceptions flying around
if (stateType == null) {
- stateType = findStateType();
+ // Cache because we don't need to do this once per instance
+ stateType = stateTypeCache.get(this.getClass());
+ if (stateType == null) {
+ stateType = findStateType();
+ stateTypeCache.put(this.getClass(), stateType);
+ }
}
return stateType;