在JacORB 3中,如何将可移植拦截器用于本地对象的实现发生了变化在发行说明中声明:"为本地对象正确实现了可移植拦截器。"这个新的实现似乎引起了一些问题;重现问题的最简单方法是从sas-demo (jacorb附带的那个)修改GssUpServer.java:
public class GssUpServer extends SASDemoPOA {
private ORB orb;
private boolean calledPrintSAS = false; // added
public GssUpServer(ORB orb) {
this.orb = orb;
}
public void printSAS() {
try {
org.omg.PortableInterceptor.Current current = (org.omg.PortableInterceptor.Current) orb
.resolve_initial_references("PICurrent");
org.omg.CORBA.Any anyName = current
.get_slot(org.jacorb.security.sas.SASInitializer.sasPrincipalNamePIC);
if (anyName.type().kind().value() == org.omg.CORBA.TCKind._tk_null) {
System.out.println("Null Name");
} else {
String name = anyName.extract_string();
System.out.println("printSAS for user " + name);
}
// /* added
if (!calledPrintSAS) {
calledPrintSAS = true;
// local call, (JacORB 3.x: throws NPE from SASClientInterceptor)
_this().printSAS();
}
// */
} catch (Exception e) {
e.printStackTrace();
}
}
...
}
GssUpClient.bat后的堆栈跟踪:
2013-04-11 11:01:24.968 SEVERE unexpected exception during servant_preinvoke org.jacorb.security.sas.SASClientInterceptor.send_request(SASClientInterceptor.java:194)
org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.invoke(ClientInterceptorIterator.java:129)
org.jacorb.orb.portableInterceptor.AbstractInterceptorIterator.iterate(AbstractInterceptorIterator.java:66)
org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.iterate(ClientInterceptorIterator.java:87)
org.jacorb.orb.DefaultClientInterceptorHandler.invokeInterceptors(DefaultClientInterceptorHandler.java:328)
org.jacorb.orb.DefaultClientInterceptorHandler.handle_send_request(DefaultClientInterceptorHandler.java:132)
org.jacorb.orb.Delegate.servant_preinvoke(Delegate.java:2505)
org.omg.CORBA.portable.ObjectImpl._servant_preinvoke(ObjectImpl.java:135)
org.jacorb.demo.sas._SASDemoStub.printSAS(_SASDemoStub.java:73)
org.jacorb.demo.sas.GssUpServer.printSAS(GssUpServer.java:46)
org.jacorb.demo.sas.SASDemoPOA._invoke(SASDemoPOA.java:47)
org.jacorb.poa.RequestProcessor.invokeOperation(RequestProcessor.java:348)
org.jacorb.poa.RequestProcessor.process(RequestProcessor.java:670)
org.jacorb.poa.RequestProcessor.run(RequestProcessor.java:820)
java.lang.NullPointerException
at org.jacorb.security.sas.SASClientInterceptor.send_request(SASClientInterceptor.java:194)
at org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.invoke(ClientInterceptorIterator.java:129)
at org.jacorb.orb.portableInterceptor.AbstractInterceptorIterator.iterate(AbstractInterceptorIterator.java:66)
at org.jacorb.orb.portableInterceptor.ClientInterceptorIterator.iterate(ClientInterceptorIterator.java:87)
at org.jacorb.orb.DefaultClientInterceptorHandler.invokeInterceptors(DefaultClientInterceptorHandler.java:328)
at org.jacorb.orb.DefaultClientInterceptorHandler.handle_send_request(DefaultClientInterceptorHandler.java:132)
at org.jacorb.orb.Delegate.servant_preinvoke(Delegate.java:2505)
at org.omg.CORBA.portable.ObjectImpl._servant_preinvoke(ObjectImpl.java:135)
at org.jacorb.demo.sas._SASDemoStub.printSAS(_SASDemoStub.java:73)
at org.jacorb.demo.sas.GssUpServer.printSAS(GssUpServer.java:46)
at org.jacorb.demo.sas.SASDemoPOA._invoke(SASDemoPOA.java:47)
at org.jacorb.poa.RequestProcessor.invokeOperation(RequestProcessor.java:348)
at org.jacorb.poa.RequestProcessor.process(RequestProcessor.java:670)
at org.jacorb.poa.RequestProcessor.run(RequestProcessor.java:820)
上面的代码在JacORB 2.3.1中工作得非常好。这个问题的简单解决方法是将属性jacorb.isLocalHistoricalInterceptors
设置为true;然而,某些"内置"方法(例如_is_a()
)不尊重这个标志(因为这些方法直接使用is_really_local()
检查对象的位置)。似乎这些"内置"方法调用在本地调用时从未使用过拦截器。
所以我的观察是:
- JacORB 3。x似乎破坏了一些本地调用的便携式拦截器(准确地说,拦截器需要connection-object…)
- JacORB 3。x似乎是第一个JacORB使用便携式拦截器对
_is_a()
,_non_existent()
,_interface()
,_get_component()
进行本地调用
第一个问题是可以解决的,因为有一个属性使JacORB 3。X可以作为旧版本使用。第二个(和第一个结合在一起)似乎真的很麻烦。
有没有其他人注意到这种行为,并且可以验证我的猜测,这确实是JacORB 3中的缺陷。x,还是我漏掉了什么?
带有本地调用的内置可移植拦截器应该能正常工作;这听起来像个bug。事实上,它听起来像使用AMI+BiDir与jacorb。我还输入了http://www.jacorb.org/bugzilla/show_bug.cgi?id=957