}
protected SharedState getState() {
+ assert getSession() == null
+ || getSession().getLock().isHeldByCurrentThread() : VaadinSession.SESSION_LOCK_MESSAGE;
if (null == sharedState) {
sharedState = createState();
}
import java.util.List;
import java.util.Locale;
import java.util.Map;
-import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Logger;
*/
public static final String UI_PARAMETER = "UI";
+ public static final String SESSION_LOCK_MESSAGE = "You are accessing UI state without proper synchronization!";
+
private static final Method BOOTSTRAP_FRAGMENT_METHOD = ReflectTools
.findMethod(BootstrapListener.class, "modifyBootstrapFragment",
BootstrapFragmentResponse.class);
.findMethod(BootstrapListener.class, "modifyBootstrapPage",
BootstrapPageResponse.class);
- private final Lock lock = new ReentrantLock();
+ private final ReentrantLock lock = new ReentrantLock();
/**
* An event sent to {@link #start(SessionStartEvent)} when a new Application
private final Map<String, Object> attributes = new HashMap<String, Object>();
+ public VaadinSession() {
+ // TODO Auto-generated constructor stub
+ }
+
/**
* @see javax.servlet.http.HttpSessionBindingListener#valueBound(HttpSessionBindingEvent)
*/
*
* @return the lock that should be used for synchronization
*/
- public Lock getLock() {
+ public ReentrantLock getLock() {
return lock;
}
import com.vaadin.server.AbstractCommunicationManager;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.GlobalResourceHandler;
+import com.vaadin.server.VaadinSession;
/**
* A class which takes care of book keeping of {@link ClientConnector}s for a
* The connector that should be marked clean.
*/
public void markDirty(ClientConnector connector) {
+ assert uI.getSession() == null
+ || uI.getSession().getLock().isHeldByCurrentThread() : VaadinSession.SESSION_LOCK_MESSAGE;
if (isWritingResponse()) {
throw new IllegalStateException(
"A connector should not be marked as dirty while a response is being written.");
final VaadinSession appWithCustomIntegerConverter = new VaadinSession();
appWithCustomIntegerConverter
.setConverterFactory(new ConverterFactory42());
+ appWithCustomIntegerConverter.getLock().lock();
TextField tf = new TextField("", "123") {
@Override
public void testApplicationConverterFactoryForDifferentThanCurrentApplication() {
final VaadinSession fieldAppWithCustomIntegerConverter = new VaadinSession();
+ fieldAppWithCustomIntegerConverter.getLock().lock();
fieldAppWithCustomIntegerConverter
.setConverterFactory(new ConverterFactory42());
VaadinSession.setCurrent(new VaadinSession());
public void testNumberDoubleConverterChange() {
final VaadinSession a = new VaadinSession();
+ a.getLock().lock();
VaadinSession.setCurrent(a);
TextField tf = new TextField() {
@Override
AbstractField field = new AbstractField() {
final private VaadinSession application = new VaadinSession() {
-
+ {
+ getLock().lock();
+ }
};
private UI uI = new UI() {
-
@Override
protected void init(WrappedRequest request) {