author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Thu, 10 Oct 2013 14:02:18 +0200 | |
changeset 309 | 7025177bd67e |
child 322 | 4a93f2679691 |
permissions | -rw-r--r-- |
jaroslav@309 | 1 |
/** |
jaroslav@309 | 2 |
* HTML via Java(tm) Language Bindings |
jaroslav@309 | 3 |
* Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jaroslav@309 | 4 |
* |
jaroslav@309 | 5 |
* This program is free software: you can redistribute it and/or modify |
jaroslav@309 | 6 |
* it under the terms of the GNU General Public License as published by |
jaroslav@309 | 7 |
* the Free Software Foundation, version 2 of the License. |
jaroslav@309 | 8 |
* |
jaroslav@309 | 9 |
* This program is distributed in the hope that it will be useful, |
jaroslav@309 | 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
jaroslav@309 | 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
jaroslav@309 | 12 |
* GNU General Public License for more details. apidesign.org |
jaroslav@309 | 13 |
* designates this particular file as subject to the |
jaroslav@309 | 14 |
* "Classpath" exception as provided by apidesign.org |
jaroslav@309 | 15 |
* in the License file that accompanied this code. |
jaroslav@309 | 16 |
* |
jaroslav@309 | 17 |
* You should have received a copy of the GNU General Public License |
jaroslav@309 | 18 |
* along with this program. Look for COPYING file in the top folder. |
jaroslav@309 | 19 |
* If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException |
jaroslav@309 | 20 |
*/ |
jaroslav@309 | 21 |
package org.apidesign.html.boot.impl; |
jaroslav@309 | 22 |
|
jaroslav@309 | 23 |
import org.apidesign.html.boot.spi.Fn; |
jaroslav@309 | 24 |
|
jaroslav@309 | 25 |
/** |
jaroslav@309 | 26 |
* |
jaroslav@309 | 27 |
* @author Jaroslav Tulach <jtulach@netbeans.org> |
jaroslav@309 | 28 |
*/ |
jaroslav@309 | 29 |
public final class FnContext { |
jaroslav@309 | 30 |
private FnContext() { |
jaroslav@309 | 31 |
} |
jaroslav@309 | 32 |
|
jaroslav@309 | 33 |
private static final ThreadLocal<Fn.Presenter> CURRENT = new ThreadLocal<Fn.Presenter>(); |
jaroslav@309 | 34 |
|
jaroslav@309 | 35 |
public static Fn.Presenter currentPresenter(Fn.Presenter p) { |
jaroslav@309 | 36 |
Fn.Presenter prev = CURRENT.get(); |
jaroslav@309 | 37 |
CURRENT.set(p); |
jaroslav@309 | 38 |
return prev; |
jaroslav@309 | 39 |
} |
jaroslav@309 | 40 |
|
jaroslav@309 | 41 |
public static Fn.Presenter currentPresenter() { |
jaroslav@309 | 42 |
Fn.Presenter p = CURRENT.get(); |
jaroslav@309 | 43 |
if (p == null) { |
jaroslav@309 | 44 |
throw new IllegalStateException("No current WebView context around!"); |
jaroslav@309 | 45 |
} |
jaroslav@309 | 46 |
return p; |
jaroslav@309 | 47 |
} |
jaroslav@309 | 48 |
|
jaroslav@309 | 49 |
} |