01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.axis.server;
17:
18: import java.lang.reflect.Method;
19: import javax.xml.rpc.holders.IntHolder;
20:
21: import org.apache.axis.providers.java.RPCProvider;
22: import org.apache.axis.MessageContext;
23: import org.apache.axis.Handler;
24: import org.apache.geronimo.webservices.WebServiceContainer;
25:
26: /**
27: * @version $Rev: 547376 $ $Date: 2007-06-14 12:38:13 -0700 (Thu, 14 Jun 2007) $
28: */
29: public class POJOProvider extends RPCProvider {
30: public POJOProvider() {
31: }
32:
33: public Object getServiceObject(MessageContext msgContext,
34: Handler service, String clsName, IntHolder scopeHolder)
35: throws Exception {
36: WebServiceContainer.Request request = (WebServiceContainer.Request) msgContext
37: .getProperty(AxisWebServiceContainer.REQUEST);
38: return request.getAttribute(WebServiceContainer.POJO_INSTANCE);
39: }
40:
41: protected Object invokeMethod(MessageContext msgContext,
42: Method interfaceMethod, Object pojo, Object[] arguments)
43: throws Exception {
44: Class pojoClass = pojo.getClass();
45:
46: Method pojoMethod = null;
47: try {
48: pojoMethod = pojoClass.getMethod(interfaceMethod.getName(),
49: interfaceMethod.getParameterTypes());
50: } catch (NoSuchMethodException e) {
51: throw (NoSuchMethodException) new NoSuchMethodException(
52: "The pojo class '"
53: + pojoClass.getName()
54: + "' does not have a method matching signature: "
55: + interfaceMethod).initCause(e);
56: }
57:
58: return pojoMethod.invoke(pojo, arguments);
59: }
60: }
|