01: /*
02: * (C) Copyright 2000 - 2005 Nabh Information Systems, Inc.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19: package com.nabhinc.ws.service.core;
20:
21: import java.lang.reflect.InvocationTargetException;
22:
23: import com.nabhinc.ws.core.UnavailableException;
24: import com.nabhinc.ws.core.WebServiceException;
25: import com.nabhinc.ws.server.RequestInfo;
26: import com.nabhinc.ws.server.WebServiceImpl;
27:
28: /**
29: * Base class for all Java Web service classes that implement service
30: * functionlity themselves, i.e. the Java class methods directly map
31: * to Web service operations.
32: *
33: * @author Padmanabh Dabke
34: * (c) 2005 Nabh Information Systems, Inc. All Rights Reserved.
35: */
36: public class BaseJavaWebService extends WebServiceImpl {
37:
38: /**
39: * Uses Java reflection to execute Web service operation.
40: */
41: public Object invoke(RequestInfo reqInfo)
42: throws WebServiceException {
43: /*
44: Method method = null;
45: try {
46: method = ReflectionUtil.getMethod(reqInfo.serviceInfo.webService,
47: reqInfo.methodName, reqInfo.arguments);
48: } catch (Exception ex) {
49: reqInfo.error = new RemoteException("Failed to find method "
50: + reqInfo.methodName
51: + " on target object of class "
52: + this.getClass().getName(), ex);
53: }
54: */
55: try {
56: return reqInfo.method.invoke(this , reqInfo.arguments);
57:
58: } catch (InvocationTargetException ex) {
59: throw new WebServiceException(ex.getMessage(), ex
60: .getCause());
61: } catch (IllegalAccessException e) {
62: throw new UnavailableException("Object method "
63: + reqInfo.methodName + " is inaccessible.");
64: }
65:
66: }
67:
68: }
|