本文整理匯總了Java中com.vaadin.server.VaadinServlet.getCurrent方法的典型用法代碼示例。如果您正苦於以下問題:Java VaadinServlet.getCurrent方法的具體用法?Java VaadinServlet.getCurrent怎麽用?Java VaadinServlet.getCurrent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vaadin.server.VaadinServlet
的用法示例。
在下文中一共展示了VaadinServlet.getCurrent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getWebApplicationContext
import com.vaadin.server.VaadinServlet; //導入方法依賴的package包/類
public static WebApplicationContext getWebApplicationContext() {
VaadinServlet servlet = VaadinServlet.getCurrent();
if (servlet != null) {
return WebApplicationContextUtils
.getRequiredWebApplicationContext(servlet.getServletContext());
} else {
return null;
}
}
示例2: init
import com.vaadin.server.VaadinServlet; //導入方法依賴的package包/類
@Override
protected void init(VaadinRequest request) {
// for mobile, set yet another theme
if (VaadinServlet.getCurrent() instanceof TouchKitServlet) {
setTheme("touchkitexex");
}
super.init(request);
}
示例3: lookup
import com.vaadin.server.VaadinServlet; //導入方法依賴的package包/類
/**
* Ищет подходящий экземпляр для интерфейса службы
*
* @param srvType Тип службы
* @return экземпляр службы
* @param <TServiceType> a TServiceType object.
*/
public static <TServiceType> TServiceType lookup(final Class<TServiceType> srvType) {
final VaadinServlet vaadinServlet = VaadinServlet.getCurrent();
if (vaadinServlet == null) {
logger.error("Couldn't get current instance of VaadinServlet");
throw new IllegalStateException("Couldn't get current instance of VaadinServlet");
}
final WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(vaadinServlet.getServletContext());
return context.getBean(srvType);
}
示例4: init
import com.vaadin.server.VaadinServlet; //導入方法依賴的package包/類
/**
* Called when <em>the first</em> UI of the session is initialized.
*/
protected void init(Locale requestLocale) {
VaadinSession vSession = VaadinSession.getCurrent();
vSession.setAttribute(App.class, this);
vSession.setLocale(messageTools.getDefaultLocale());
// set root error handler for all session
vSession.setErrorHandler(event -> {
try {
getExceptionHandlers().handle(event);
getAppLog().log(event);
} catch (Throwable e) {
//noinspection ThrowableResultOfMethodCallIgnored
log.error("Error handling exception\nOriginal exception:\n{}\nException in handlers:\n{}",
ExceptionUtils.getStackTrace(event.getThrowable()), ExceptionUtils.getStackTrace(e)
);
}
});
appLog = new AppLog();
connection = createConnection();
exceptionHandlers = new ExceptionHandlers(this);
cookies = new AppCookies();
themeConstants = loadTheme();
VaadinServlet vaadinServlet = VaadinServlet.getCurrent();
ServletContext sc = vaadinServlet.getServletContext();
String resourcesTimestamp = sc.getInitParameter("webResourcesTs");
if (StringUtils.isNotEmpty(resourcesTimestamp)) {
this.webResourceTimestamp = resourcesTimestamp;
}
log.debug("Initializing application");
// get default locale from config
Locale targetLocale = resolveLocale(requestLocale);
setLocale(targetLocale);
}