1 package eu
.etaxonomy
.taxeditor
.service
;
3 import java
.io
.IOException
;
4 import java
.io
.OutputStream
;
6 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
7 import org
.springframework
.remoting
.httpinvoker
.HttpInvokerClientConfiguration
;
8 import org
.springframework
.remoting
.support
.RemoteInvocation
;
9 import org
.springframework
.remoting
.support
.RemoteInvocationResult
;
10 import org
.springframework
.stereotype
.Component
;
12 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionManager
;
15 public class CdmServiceRequestExecutor
extends CdmAuthenticatedHttpInvokerRequestExecutor
{
18 private ICdmEntitySessionManager cdmEntitySessionManager
;
20 private RemoteInvocation currentRemoteInvocation
;
23 protected void writeRemoteInvocation(RemoteInvocation invocation
, OutputStream os
) throws IOException
{
24 currentRemoteInvocation
= invocation
;
25 super.writeRemoteInvocation(invocation
, os
);
29 protected RemoteInvocationResult
doExecuteRequest(HttpInvokerClientConfiguration config
,
30 java
.io
.ByteArrayOutputStream baos
)
31 throws java
.io
.IOException
,
32 java
.lang
.ClassNotFoundException
{
33 RemoteInvocationResult rir
= fromCache(currentRemoteInvocation
);
35 // if rir is not null at this point we assume that the
36 // the object has already been loaded in the cache and
37 // does not need to be reloaded
40 rir
= super.doExecuteRequest(config
, baos
);
41 if(rir
.getValue() != null && !rir
.hasException()) {
42 rir
= new RemoteInvocationResult(cdmEntitySessionManager
.load(rir
.getValue()));
44 cache(currentRemoteInvocation
, rir
);
46 currentRemoteInvocation
= null;
51 public void cache(RemoteInvocation ri
, RemoteInvocationResult rir
) {
55 public RemoteInvocationResult
fromCache(RemoteInvocation ri
) {