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.openejb.server.axis.client;
17:
18: import net.sf.cglib.proxy.MethodInterceptor;
19: import net.sf.cglib.proxy.MethodProxy;
20:
21: import javax.xml.rpc.ServiceException;
22: import java.lang.reflect.Method;
23: import java.util.Map;
24:
25: public class ServiceMethodInterceptor implements MethodInterceptor {
26: private final Map seiFactoryMap;
27:
28: public ServiceMethodInterceptor(Map seiFactoryMap) {
29: this .seiFactoryMap = seiFactoryMap;
30: }
31:
32: public Object intercept(Object o, Method method, Object[] objects,
33: MethodProxy methodProxy) throws Throwable {
34: if (objects.length == 0) {
35: String methodName = method.getName();
36: if (methodName.startsWith("get")) {
37: String portName = methodName.substring(3);
38: SeiFactory seiFactory = (SeiFactory) seiFactoryMap
39: .get(portName);
40: if (seiFactory != null) {
41: return seiFactory.createServiceEndpoint();
42: }
43: }
44: }
45: throw new ServiceException(
46: "Unrecognized method name or argument list: "
47: + method.getName());
48: }
49: }
|