本文整理汇总了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);
}