本文整理汇总了Java中com.vaadin.util.CurrentInstance类的典型用法代码示例。如果您正苦于以下问题:Java CurrentInstance类的具体用法?Java CurrentInstance怎么用?Java CurrentInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CurrentInstance类属于com.vaadin.util包,在下文中一共展示了CurrentInstance类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testFromRequest
import com.vaadin.util.CurrentInstance; //导入依赖的package包/类
@Test
public void testFromRequest() {
final DeviceInfo di = DeviceInfo.create(VaadinService.getCurrentRequest());
assertNotNull(di);
VaadinSession session = mock(VaadinSession.class);
when(session.getState()).thenReturn(VaadinSession.State.OPEN);
when(session.getSession()).thenReturn(mock(WrappedSession.class));
when(session.getService()).thenReturn(mock(VaadinServletService.class));
when(session.getSession().getId()).thenReturn(TEST_SESSION_ID);
when(session.hasLock()).thenReturn(true);
when(session.getLocale()).thenReturn(Locale.US);
when(session.getAttribute(DeviceInfo.SESSION_ATTRIBUTE_NAME)).thenReturn(di);
CurrentInstance.set(VaadinSession.class, session);
Optional<DeviceInfo> odi = DeviceInfo.get();
assertTrue(odi.isPresent());
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:22,代码来源:TestDeviceInfo.java
示例2: testInitNotMatchedPagelet
import com.vaadin.util.CurrentInstance; //导入依赖的package包/类
@Test
public void testInitNotMatchedPagelet() throws Exception {
// variables
String path = "/test";
// mocks
VaadinPageletTracker pageletTracker = createMock(VaadinPageletTracker.class);
VaadinRequest request = createMock(VaadinRequest.class);
// expect getting url path from request
expect(request.getPathInfo()).andReturn(path);
// expect matching path to pagelet
expect(pageletTracker.matchPathToPagelet(path)).andReturn(null);
// except returning HTTP 404
VaadinResponse response = createMock(VaadinResponse.class);
expect(CurrentInstance.get(VaadinResponse.class)).andReturn(response);
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found");
// perform test
replayAll();
PageletAwareUI ui = new PageletAwareUI(pageletTracker);
ui.init(request);
verifyAll();
}
开发者ID:panifex,项目名称:panifex-platform,代码行数:27,代码来源:PageletAwareUITest.java
示例3: getConversationId
import com.vaadin.util.CurrentInstance; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public String getConversationId() {
Integer uiId = null;
UI ui = UI.getCurrent();
if (ui == null) {
UIid id = CurrentInstance.get(UIid.class);
if (id != null) {
uiId = id.getUiId();
}
}
else if (ui != null) {
if (!sessions.containsKey(ui)) {
ui.addDetachListener(this);
sessions.put(ui, VaadinSession.getCurrent().getSession().getId());
}
uiId = ui.getUIId();
}
return uiId != null ? getConversationId(uiId) : null;
}
开发者ID:chelu,项目名称:jdal,代码行数:25,代码来源:VaadinScope.java
示例4: createUi
import com.vaadin.util.CurrentInstance; //导入依赖的package包/类
/**
* Create a Vaadin UI using given UI class
* @param <T> UI type
* @param uiClass UI class to create
* @return UI instance
*/
@SuppressWarnings("unchecked")
protected <T extends UI> T createUi(Class<T> uiClass) {
T ui = (T) uiProvider.createInstance(buildUiCreateEvent(uiClass, null));
CurrentInstance.set(UI.class, ui);
return ui;
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:13,代码来源:AbstractVaadinTest.java
示例5: createInstance
import com.vaadin.util.CurrentInstance; //导入依赖的package包/类
@Override
public UI createInstance(UICreateEvent event) {
final Class<UIID> key = UIID.class;
final UIID identifier = new UIID(event);
CurrentInstance.set(key, identifier);
try {
Class<? extends UI> uiClass = event.getUIClass();
logger.debug("Creating a new UI bean of class [{}] with identifier [{}]",
uiClass.getCanonicalName(), identifier);
return applicationContext.getBean(uiClass);
} finally {
CurrentInstance.set(key, null);
}
}
开发者ID:peholmst,项目名称:vaadin4spring,代码行数:15,代码来源:SpringAwareUIProvider.java
示例6: createInstance
import com.vaadin.util.CurrentInstance; //导入依赖的package包/类
@Override
public UI createInstance(UICreateEvent event) {
ApplicationContext ctx = VaadinUtils.getApplicationContext();
CurrentInstance.set(UIid.class, new UIid(event.getUiId()));
UI ui = this.uiMapping.getUi(event.getRequest());
if (ui == null)
ui = ctx.getBean(event.getUIClass());
CurrentInstance.set(UIid.class, null);
return ui;
}
开发者ID:chelu,项目名称:jdal,代码行数:14,代码来源:SpringUIProvider.java
示例7: setUp
import com.vaadin.util.CurrentInstance; //导入依赖的package包/类
@Before
public void setUp() {
resetAll();
mockStatic(CurrentInstance.class);
}
开发者ID:panifex,项目名称:panifex-platform,代码行数:7,代码来源:PageletAwareUITest.java
示例8: setup
import com.vaadin.util.CurrentInstance; //导入依赖的package包/类
@Before
public void setup() throws Exception {
vaadinSession = createVaadinSession(getClientLocale());
CurrentInstance.set(VaadinSession.class, vaadinSession);
CurrentInstance.set(VaadinRequest.class, buildVaadinRequest());
uiProvider = buildUiProvider();
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:11,代码来源:AbstractVaadinTest.java
示例9: buildUiCreateEvent
import com.vaadin.util.CurrentInstance; //导入依赖的package包/类
/**
* Build the UICreateEvent to pass to UIProvider
* @param uiClass UI class
* @param location Optional Page location
* @return UICreateEvent
*/
protected UICreateEvent buildUiCreateEvent(Class<? extends UI> uiClass, String location) {
VaadinServletRequest request = (location != null) ? buildVaadinRequest(location) : buildVaadinRequest();
CurrentInstance.set(VaadinRequest.class, request);
CurrentInstance.set(VaadinSession.class, vaadinSession);
return new UICreateEvent(request, uiClass, TEST_UIID);
}
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:16,代码来源:AbstractVaadinTest.java
注:本文中的com.vaadin.util.CurrentInstance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论