@Endpoint and @Transactional on the same class using Spring-ws library -
i trying implement web-service endpoint transactional because don't want create special "worker" class transactional methods. i'm using spring-ws library spring framework.
here class definition:
@endpoint @transactional @scope(proxymode=scopedproxymode.target_class) public class myendpoint implements applicationcontextaware { ... }
notice explicitly specified proxying method force using cglib.
also notice class implements interface(s), default spring uses jdk dynamic proxy unless proxying method specified. kind of proxies not appropriate in case.
the problem begins on application deployment when payloadrootannotationmethodendpointmapping
class starts working. collects names of spring beans @endpoint
annotation. endpoint class counted twice names "myendpoint
" , "scopedtarget.myendpoint
". duplication causes applicationcontextexception
message "cannot map endpoint [...] on registration key [...]: there's endpoint [...] mapped".
question: how can make endpoint class being transactional?
you might write own payloadrootannotationmethodendpointmapping
extension , override initapplicationcontext
method. there can check scopedtarget.
prefix filter out unwanted beans:
public class proxiedbeanawareendpointmapping extends payloadrootannotationmethodendpointmapping { @override protected void initapplicationcontext() throws beansexception { initinterceptors(); string[] beannames = getapplicationcontext().getbeannamesfortype(object.class); (string beanname : beannames) { if (!beanname.startswith("scopedtarget.")) { class<?> endpointclass = getapplicationcontext().gettype(beanname); if (endpointclass != null && annotationutils.findannotation(endpointclass, getendpointannotationtype()) != null) { registermethods(beanname); } } } } }
or can use open session in view approach don't need proxy @endpoint
s.
Comments
Post a Comment