Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
DefaultMethodInvocationStrategy |
|
| 0.0;0 |
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. 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 | package org.apache.camel.spring.util; |
|
18 | ||
19 | import java.util.Map; |
|
20 | import java.util.concurrent.ConcurrentHashMap; |
|
21 | ||
22 | import org.aopalliance.intercept.MethodInvocation; |
|
23 | import org.apache.camel.Expression; |
|
24 | import org.apache.camel.Exchange; |
|
25 | import org.apache.camel.Endpoint; |
|
26 | import org.apache.camel.RuntimeCamelException; |
|
27 | import org.apache.camel.Message; |
|
28 | import org.apache.camel.builder.ExpressionBuilder; |
|
29 | ||
30 | /** |
|
31 | * Represents the strategy used to figure out how to map a message exchange to a POJO method invocation |
|
32 | * |
|
33 | * @version $Revision:$ |
|
34 | */ |
|
35 | public class DefaultMethodInvocationStrategy implements MethodInvocationStrategy { |
|
36 | ||
37 | 4 | private Map<Class, Expression> parameterTypeToExpressionMap = new ConcurrentHashMap<Class, Expression>(); |
38 | ||
39 | 4 | public DefaultMethodInvocationStrategy() { |
40 | 4 | } |
41 | ||
42 | public synchronized Expression getDefaultParameterTypeExpression(Class parameterType) { |
|
43 | 1 | return parameterTypeToExpressionMap.get(parameterType); |
44 | } |
|
45 | ||
46 | /** |
|
47 | * Adds a default parameter type mapping to an expression |
|
48 | */ |
|
49 | public synchronized void addParameterMapping(Class parameterType, Expression expression) { |
|
50 | 0 | parameterTypeToExpressionMap.put(parameterType, expression); |
51 | 0 | } |
52 | ||
53 | ||
54 | /** |
|
55 | * Creates an invocation on the given POJO using annotations to decide which method to invoke |
|
56 | * and to figure out which parameters to use |
|
57 | */ |
|
58 | /* |
|
59 | public MethodInvocation createInvocation(Object pojo, |
|
60 | BeanInfo beanInfo, |
|
61 | Exchange messageExchange, |
|
62 | Endpoint pojoEndpoint) throws RuntimeCamelException { |
|
63 | return beanInfo.createInvocation(pojo, messageExchange); |
|
64 | } |
|
65 | */ |
|
66 | ||
67 | ||
68 | public void loadDefaultRegistry() { |
|
69 | 0 | addParameterMapping(Exchange.class, ExpressionBuilder.exchangeExpression()); |
70 | 0 | addParameterMapping(Message.class, ExpressionBuilder.inMessageExpression()); |
71 | 0 | } |
72 | ||
73 | ||
74 | } |