01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: SoapXFireObjectInvoker.java 3674 2007-02-27 12:09:09Z gbevin $
07: */
08: package com.uwyn.rife.engine.elements;
09:
10: import java.lang.reflect.Method;
11: import org.codehaus.xfire.MessageContext;
12: import org.codehaus.xfire.fault.XFireFault;
13: import org.codehaus.xfire.service.Service;
14: import org.codehaus.xfire.service.invoker.AbstractInvoker;
15: import org.codehaus.xfire.service.invoker.FactoryInvoker;
16: import org.codehaus.xfire.service.invoker.LocalFactory;
17: import org.codehaus.xfire.service.invoker.ScopePolicy;
18:
19: // FIXME: needs a better implementation as soon as XFire 1.2.3 is released, the Invoker API is currently a bit broken
20: class SoapXFireObjectInvoker extends AbstractInvoker {
21: /**
22: * Constant to denote the implementation class for the service.
23: */
24: public static final String SERVICE_IMPL_CLASS = "xfire.serviceImplClass";
25:
26: // localfactory uses a ThreadLocal to ensure thread safety.
27: // using localfactory, we don't need to "new" at each request.
28: private static final LocalFactory LOCALFACTORY = new LocalFactory(
29: SERVICE_IMPL_CLASS);
30:
31: private final FactoryInvoker fwd;
32:
33: private final ScopePolicy policy;
34:
35: public SoapXFireObjectInvoker(ScopePolicy policy) {
36: this .policy = policy;
37: this .fwd = new SoapXFireFactoryInvoker(LOCALFACTORY, policy);
38: }
39:
40: public Object invoke(Method m, Object[] params,
41: MessageContext context) throws XFireFault {
42: final Service service = context.getService();
43: LOCALFACTORY.setService(service);
44: return fwd.invoke(m, params, context);
45: }
46:
47: public Object getServiceObject(final MessageContext context)
48: throws XFireFault {
49: final Service service = context.getService();
50: LOCALFACTORY.setService(service);
51: return fwd.getServiceObject(context);
52: }
53:
54: /**
55: * Get the scope policy used by this class.
56: */
57: public ScopePolicy getScope() {
58: return policy;
59: }
60: }
|