我正在使用飞碟xhtmlrenderer来构建pdf文档.到目前为止一切正常 - 现在我们应该在pdf中生成阿拉伯语文本.Xhtmlrenderer以相反的顺序呈现阿拉伯语文本.
我在网上(可能在他们自己的网站上)读过xhtmlrenderer不支持bidi/rtl的地方.但IText本身包含通过ColumnText和PdfPTable处理阿拉伯语和希伯来语的示例(可在此处找到源代码:http://sourceforge.net/projects/itextpdf/files/Examples/examples-155/examples-155.zip/download - arabic_hebrew.java),那些工作正常.
我试图在xhtmlrenderer的ReplacedElementFactory/ITextReplacedElement中使用itext api,但找不到定位元素的好例子.有没有人试过这样做?或者可能有一个更简单(或至少工作)的解决方案?
如果在调用构建流链的任何元素期间发生异常,是否有一种方法可以关闭Stream?
例如,代码:
Stream.of(new Object())
.filter(e -> {
if (true) throw new IllegalStateException();
return true;
})
.onClose(() -> System.out.println("OnClose"))
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
将产生以下输出:
Exception in thread "main" java.lang.IllegalStateException
at my.className.lambda$main$2(LdapRealm.java:114)
at my.className$$Lambda$1/1607521710.test(Unknown Source)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
at java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:419)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at my.className.main(LdapRealm.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Run Code Online (Sandbox Code Playgroud)
请注意,未打印"OnClose"消息,因为尚未调用onClose().如果我希望第三方代码使用此流并且我不确定该代码是否有助于try/catch+ Autocloseable功能,是否有任何解决此问题的好方法?
在我的Vaadin应用程序中,当Vaadin在"会话超时"消息后没有使会话无效时,我遇到了问题.收到此消息后,用户有时可以单击链接或刷新页面并继续工作,就好像他们仍在登录一样.我使用以下参数:
closeIdleSessions=true
heartbeatInterval=60
session-timeout=15
Run Code Online (Sandbox Code Playgroud)
最后一个参数(会话超时)也在context.xml(session-timeout = 900)和web.xml(session-config/session-timeout = 15)中设置,因为我没有从vaadin文档中得到清楚,是否有这样的vaadin servlet的参数与否.
有人面对名义上的问题吗?
更新1:固定参数片段.
更新2:出现消息SessionDestroyListener.sessionDestroy时不会触发Session expired.
更新3:由于代码错误而出现上一个错误.现在SessionDestroyListener.sessionDestroy被调用,但我无法访问给HttpSession定的事件.
这是我的SessionDestroyListener代码(请注意其中一个if分支的评论):
private static class SynchronizerSessionDestroyListener implements SessionDestroyListener {
@Override
public void sessionDestroy(SessionDestroyEvent event) {
if (event.getSession() != null){
WrappedSession wrappedSession = event.getSession().getSession();
if (wrappedSession instanceof WrappedHttpSession){
WrappedHttpSession wrappedHttpSession = (WrappedHttpSession) wrappedSession;
HttpSession httpSession = wrappedHttpSession.getHttpSession();
if (httpSession != null){
try {
httpSession.invalidate();
logger.debug("Session '{}' was invalidated", httpSession.getId());
} catch (IllegalStateException …Run Code Online (Sandbox Code Playgroud)