Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何通过运行时查找知道返回的对象是什么类型的 EJB?
只知道是否是有状态的对我有好处。
bound = new InitialContext().lookup(lookup); if(isStateful(bound)){...}
我当前的应用程序服务器是 JBoss AS 6.1
这取决于...您是否使用注释Stateful和Stateless?
Stateful
Stateless
final Class<?> clazz = bound.getClass(); if (clazz.isAnnotationPresent(Stateful.class)) { /* stateful */ } else if (clazz.isAnnotationPresent(Stateless.class)) { /* stateless */ } else { /* woops? */ }