本文整理汇总了Java中com.vaadin.server.RequestHandler类的典型用法代码示例。如果您正苦于以下问题:Java RequestHandler类的具体用法?Java RequestHandler怎么用?Java RequestHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestHandler类属于com.vaadin.server包,在下文中一共展示了RequestHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRequestHandlers
import com.vaadin.server.RequestHandler; //导入依赖的package包/类
@Override
protected List<RequestHandler> createRequestHandlers()
throws ServiceException {
List<RequestHandler> handlers = super.createRequestHandlers();
handlers.add(0, new ServletBootstrapHandler());
handlers.add(new ServletUIInitHandler());
if (isAtmosphereAvailable()) {
handlers.add((RequestHandler) (session, request, response) -> {
if (!ServletPortletHelper.isPushRequest(request)) {
return false;
}
if (request instanceof VertxVaadinRequest) {
((VertxVaadinRequest) request).getRoutingContext().next();
}
return true;
});
}
return handlers;
}
示例2: initRequestHandler
import com.vaadin.server.RequestHandler; //导入依赖的package包/类
/**
* initalize a unique RequestHandler
*/
private void initRequestHandler() {
if (this.requestHandlerUri == null) {
this.requestHandlerUri = UUID.randomUUID()
.toString();
VaadinSession.getCurrent()
.addRequestHandler(new RequestHandler() {
@Override
public boolean handleRequest(final VaadinSession session, final VaadinRequest request, final VaadinResponse response)
throws IOException {
if (String.format("/%s", Jcrop.this.requestHandlerUri)
.equals(request.getPathInfo())) {
Jcrop.this.resource.getStream()
.writeResponse(request, response);
return true;
} else {
return false;
}
}
});
}
}
示例3: servletInitialized
import com.vaadin.server.RequestHandler; //导入依赖的package包/类
@Override
protected void servletInitialized() throws ServletException {
super.servletInitialized();
HeaderTagHandler.init(getService());
getService().addSessionInitListener(new SessionInitListener() {
@Override
public void sessionInit(SessionInitEvent event) throws ServiceException {
event.getSession().addRequestHandler(new RequestHandler() {
@Override
public boolean handleRequest(VaadinSession session, VaadinRequest request,
VaadinResponse response) throws IOException {
String pathInfo = request.getPathInfo();
InputStream in = null;
if (pathInfo.endsWith("sw.js")) {
response.setContentType("application/javascript");
in = getClass().getResourceAsStream("/sw.js");
}
if (in != null) {
OutputStream out = response.getOutputStream();
IOUtils.copy(in, out);
in.close();
out.close();
return true;
} else {
return false;
}
}
});
}
});
}
示例4: createRequestHandler
import com.vaadin.server.RequestHandler; //导入依赖的package包/类
/**
* Creates the parameter handler that will be invoked when the user returns
* from the OAuth service.
*
* @return the parameter handler
*/
protected RequestHandler createRequestHandler() {
return new RequestHandler() {
public boolean handleRequest(VaadinSession session,
VaadinRequest request, VaadinResponse response)
throws IOException {
if (request.getParameterMap().containsKey(getVerifierName())) {
String v = request.getParameter(getVerifierName());
Verifier verifier = new Verifier(v);
accessToken = service
.getAccessToken(requestToken, verifier);
User user = getUser();
VaadinSession.getCurrent().removeRequestHandler(handler);
handler = null;
//String url = getAuthUrl();
//callbackPage.open(url, "Authentificate", 400, 300, BorderStyle.DEFAULT);
authListener.userAuthenticated(user);
} else if (getFailureParameters() != null) {
for (String key : getFailureParameters()) {
if (request.getParameterMap().containsKey(key)) {
authListener.failed(request.getParameter(key));
break;
}
}
}
return true;
}
};
}