• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CurrentInstance类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HttpMessageWriter类代码示例发布时间:2022-05-23
下一篇:
Java BindRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap