|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| XStreamRegistry.java | 100% | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
/**
|
|
| 2 |
*
|
|
| 3 |
* Copyright 2004 Protique Ltd
|
|
| 4 |
*
|
|
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 6 |
* you may not use this file except in compliance with the License.
|
|
| 7 |
* You may obtain a copy of the License at
|
|
| 8 |
*
|
|
| 9 |
* 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 |
*
|
|
| 17 |
**/
|
|
| 18 |
package org.codehaus.activesoap.handler.xstream;
|
|
| 19 |
|
|
| 20 |
import org.codehaus.activesoap.handler.DefaultHandlerRegistry;
|
|
| 21 |
import org.codehaus.activesoap.handler.DefaultHandlerRegistry;
|
|
| 22 |
import org.codehaus.activesoap.handler.DefaultHandlerRegistry;
|
|
| 23 |
|
|
| 24 |
import javax.xml.namespace.QName;
|
|
| 25 |
import java.lang.reflect.Method;
|
|
| 26 |
|
|
| 27 |
/**
|
|
| 28 |
* @version $Revision: 1.3 $
|
|
| 29 |
*/
|
|
| 30 |
public class XStreamRegistry extends DefaultHandlerRegistry { |
|
| 31 |
|
|
| 32 |
/**
|
|
| 33 |
* Allows simple services to be registered based on the types of their parameters.
|
|
| 34 |
*
|
|
| 35 |
* @param serviceClass
|
|
| 36 |
*/
|
|
| 37 | 7 |
public void registerService(Class serviceClass) throws IllegalAccessException, NoSuchFieldException { |
| 38 | 7 |
Method[] methods = serviceClass.getMethods(); |
| 39 | 7 |
for (int i = 0, size = methods.length; i < size; i++) { |
| 40 | 70 |
Method method = methods[i]; |
| 41 | 70 |
Class[] parameterTypes = method.getParameterTypes(); |
| 42 | 70 |
if (parameterTypes.length == 1) {
|
| 43 | 21 |
registerServiceMethod(serviceClass, method, parameterTypes[0]); |
| 44 |
} |
|
| 45 |
} |
|
| 46 |
} |
|
| 47 |
|
|
| 48 | 21 |
protected void registerServiceMethod(Class serviceClass, Method method, Class parameterType) throws NoSuchFieldException, IllegalAccessException { |
| 49 | 21 |
QName name = new QName(parameterType.getName());
|
| 50 | 21 |
addHandler(name, new XStreamInvokeMethodHandler(serviceClass, method));
|
| 51 |
} |
|
| 52 |
} |
|
| 53 |
|
|
||||||||||