/*
* Copyright 2000-2013 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.util;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinResponse;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
import com.vaadin.ui.UI;
/**
* Keeps track of various current instances for the current thread. All the
* instances are automatically cleared after handling a request from the client
* to avoid leaking memory. The inheritable values are also maintained when
* execution is moved to another thread, both when a new thread is created and
* when {@link VaadinSession#access(Runnable)} or {@link UI#access(Runnable)} is
* used.
*
* Currently the framework uses the following instances:
*
*
* Inheritable: {@link UI}, {@link VaadinService}, {@link VaadinSession}.
*
*
* Non-inheritable: {@link VaadinRequest}, {@link VaadinResponse}.
*
*
* @author Vaadin Ltd
* @since 7.0.0
*/
public class CurrentInstance implements Serializable {
private final Object instance;
private final boolean inheritable;
private static InheritableThreadLocal