当前位置: 首页>>代码示例>>Java>>正文


Java VaadinServletService类代码示例

本文整理汇总了Java中com.vaadin.server.VaadinServletService的典型用法代码示例。如果您正苦于以下问题:Java VaadinServletService类的具体用法?Java VaadinServletService怎么用?Java VaadinServletService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VaadinServletService类属于com.vaadin.server包,在下文中一共展示了VaadinServletService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createVaadinSession

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
/**
 * Create a VaadinSession
 * @param locale Client locale
 * @return VaadinSession instance
 * @throws Exception Failed to create session
 */
protected VaadinSession createVaadinSession(Locale locale) throws Exception {
	WrappedSession wrappedSession = mock(WrappedSession.class);
	VaadinServletService vaadinService = mock(VaadinServletService.class);
	when(vaadinService.getDeploymentConfiguration())
			.thenReturn(new DefaultDeploymentConfiguration(VaadinServletService.class, getDeploymentProperties()));

	VaadinSession session = mock(VaadinSession.class);
	when(session.getState()).thenReturn(VaadinSession.State.OPEN);
	when(session.getSession()).thenReturn(wrappedSession);
	when(session.getService()).thenReturn(vaadinService);
	when(session.getSession().getId()).thenReturn(TEST_SESSION_ID);
	when(session.hasLock()).thenReturn(true);
	when(session.getLocale()).thenReturn(locale != null ? locale : Locale.US);
	return session;
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:22,代码来源:AbstractVaadinTest.java

示例2: buildVaadinRequest

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
@SuppressWarnings("serial")
@Override
protected VaadinServletRequest buildVaadinRequest(String location) {
	return new SpringVaadinServletRequest(request, (VaadinServletService) vaadinSession.getService(), false) {

		/*
		 * (non-Javadoc)
		 * @see javax.servlet.ServletRequestWrapper#getParameter(java.lang.String)
		 */
		@Override
		public String getParameter(String name) {
			if ("v-loc".equals(name)) {
				return location;
			}
			return super.getParameter(name);
		}
	};
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:19,代码来源:AbstractVaadinSpringTest.java

示例3: buildVaadinRequest

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
/**
 * Build VaadinServletRequest using a location
 * @param location Page location
 * @return VaadinServletRequest
 */
@SuppressWarnings("serial")
protected VaadinServletRequest buildVaadinRequest(final String location) {
	return new VaadinServletRequest(buildHttpServletRequest(), (VaadinServletService) vaadinSession.getService()) {

		/*
		 * (non-Javadoc)
		 * @see javax.servlet.ServletRequestWrapper#getParameter(java.lang.String)
		 */
		@Override
		public String getParameter(String name) {
			if ("v-loc".equals(name)) {
				return location;
			}
			return super.getParameter(name);
		}

	};
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:24,代码来源:AbstractVaadinTest.java

示例4: testFromRequest

import com.vaadin.server.VaadinServletService; //导入依赖的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

示例5: getStaticFileLocation

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
@Override
public String getStaticFileLocation(VaadinRequest request) {
    String staticFileLocation;
    // if property is defined in configurations, use that
    staticFileLocation = getDeploymentConfiguration().getResourcesPath();
    if (staticFileLocation != null) {
        return staticFileLocation;
    }

    VertxVaadinRequest vertxRequest = (VertxVaadinRequest) request;
    String requestedPath = vertxRequest.getRequest().path()
        .substring(
            Optional.ofNullable(vertxRequest.getRoutingContext().mountPoint())
                .map(String::length).orElse(0)
        );
    return VaadinServletService.getCancelingRelativePath(requestedPath);
}
 
开发者ID:mcollovati,项目名称:vaadin-vertx-samples,代码行数:18,代码来源:VertxVaadinService.java

示例6: validate

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
@Override
public boolean validate(String username, String password) {
	UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
	try {
		Authentication auth = this.authenticationManager.authenticate(token);
		if (auth.isAuthenticated()) {
			// execute session authentication strategy
			if (this.sessionStrategy != null)
				this.sessionStrategy.onAuthentication(auth, VaadinServletService.getCurrentServletRequest(),
						VaadinServletService.getCurrentResponse());
			SecurityContextHolder.getContext().setAuthentication(auth);
			// save request in context session
			VaadinSession.getCurrent().getSession().setAttribute(
					HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
					SecurityContextHolder.getContext());
			
			return  true;
		}
		SecurityContextHolder.clearContext();
		return false;
	}
	catch(AuthenticationException ae) {
		SecurityContextHolder.clearContext();
		return false;
	}
}
 
开发者ID:chelu,项目名称:jdal,代码行数:27,代码来源:SpringAuthManager.java

示例7: createServletService

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
@Override
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration)
		throws ServiceException {
	JMeterService service = new JMeterService(this, deploymentConfiguration);
	service.init();
	return service;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:8,代码来源:AppServletJMeter.java

示例8: getLogoutUrl

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
private String getLogoutUrl() {
    if (VaadinServletService.getCurrentRequest() != null) {
        return VaadinServletService.getCurrentRequest().getContextPath();
    } else {
        return "https://" + this.server.getServerIpAddress() + "/";
    }
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:8,代码来源:MainUI.java

示例9: getCurrentPageUrl

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
private static String getCurrentPageUrl(ServerApi server) {
    String url;
    if (Page.getCurrent() != null && Page.getCurrent().getLocation() != null) {
        url = Page.getCurrent().getLocation().toString();
    } else if (VaadinServletService.getCurrentRequest() != null) {
        url = VaadinServletService.getCurrentRequest().getContextPath();
    } else {
        url = "https://" + server.getServerIpAddress() + "/";
    }
    // Workaround bug in URL generation
    url = url.replace("#!", "/#!");
    url = url.replace("//#!", "/#!");
    return url;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:15,代码来源:ViewUtil.java

示例10: createServletService

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
@Override
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration)
        throws ServiceException {
    VaadinServletService servletService = super.createServletService(deploymentConfiguration);
    servletService.addSessionInitListener(e -> e.getSession().addUIProvider(this.uiProvider));
    servletService.addSessionInitListener(e -> sessions.add(e.getSession()));
    servletService.addSessionDestroyListener(e -> sessions.remove(e.getSession()));
    return servletService;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:10,代码来源:UiServlet.java

示例11: servletInitialized

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
@Override
protected void servletInitialized() throws ServletException {
	super.servletInitialized();

	// register session init/destroy listeners
	final VaadinServletService service = getService();
	sessionInitListeners.forEach(listener -> service.addSessionInitListener(listener));
	sessionDestroyListeners.forEach(listener -> service.addSessionDestroyListener(listener));
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:10,代码来源:HolonVaadinServlet.java

示例12: listen

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
public void listen(@Observes
AnswerSavedEvent event) {
    RespondentAccount respondent = (RespondentAccount) VaadinServletService.getCurrentServletRequest()
            .getUserPrincipal();
    Integer questionnaireId = respondent.getGrantedquestionnaireIds().iterator().next();

    Answer answer = event.getAnswer();
    String questionCode = event.getQuestionCode();

    logger.debug("Trying to save answer: {}  for questionnair identified with id  = {} and questionCode = {}",
            answer, questionnaireId, questionCode);
    questionnaireResource.saveAnswer(answer, questionnaireId, questionCode);
}
 
开发者ID:antoniomaria,项目名称:gazpachoquest,代码行数:14,代码来源:AnswerSavedListener.java

示例13: testServletInitializedMethod

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
@Test
public void testServletInitializedMethod() throws Exception {
    // expect adding session init listener
    VaadinServletService servletService = createMock(VaadinServletService.class);
    Whitebox.setInternalState(servlet, "servletService", servletService);
    servletService.addSessionInitListener(sessionInitListenerMock);

    replayAll();
    try {
        servlet.servletInitialized();
    } finally {
        verifyAll();
    }
}
 
开发者ID:panifex,项目名称:panifex-platform,代码行数:15,代码来源:ModularVaadinServletTest.java

示例14: createServletService

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
@Override
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException {
    VaadinServletService servletService = super.createServletService(deploymentConfiguration);
    servletService.addSessionInitListener(new SessionInitListener() {
        @Override
        public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException {
            sessionInitEvent.getSession().addUIProvider(provider);
        }
    });
    return servletService;
}
 
开发者ID:peergreen,项目名称:vaadin-osgi,代码行数:12,代码来源:BaseVaadinServlet.java

示例15: modifyBootstrapPage

import com.vaadin.server.VaadinServletService; //导入依赖的package包/类
@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {

    ViewPortSettings viewPortSettings2 = selectViewPortSettings(response);
    if (viewPortSettings2 != null) {
        viewPortSettings2.modifyBootstrapPage(response);
    }
    if (getWebAppSettings() != null) {
        getWebAppSettings().modifyBootstrapPage(response);
    }
    if (getApplicationIcons() != null) {
        getApplicationIcons().modifyBootstrapPage(response);
    }
    if (getApplicationCacheSettings() != null) {
        OfflineModeEnabled offline = null;
        CacheManifestEnabled manifest = null;

        Class<?> clazz = response.getUiClass();
        if (clazz != null) {
            offline = clazz.getAnnotation(OfflineModeEnabled.class);
            manifest = clazz.getAnnotation(CacheManifestEnabled.class);
        }
        if (response.getSession().getService() instanceof VaadinServletService) {
            clazz = ((VaadinServletService) response.getSession()
                    .getService()).getServlet().getClass();
            if (offline == null) {
                offline = clazz.getAnnotation(OfflineModeEnabled.class);
            }
            if (manifest == null) {
                manifest = clazz.getAnnotation(CacheManifestEnabled.class);
            }
        }

        getApplicationCacheSettings().setCacheManifestEnabled(
                manifest == null || manifest.value());
        getApplicationCacheSettings().setOfflineModeEnabled(
                offline == null || offline.value());
        getApplicationCacheSettings().modifyBootstrapPage(response);
    }
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:41,代码来源:TouchKitSettings.java


注:本文中的com.vaadin.server.VaadinServletService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。