|
|||||||||||||||||||
| 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 | |||||||||||||||
| LingoRemoteInvocationFactory.java | 75% | 90.9% | 100% | 88.9% |
|
||||||||||||||
| 1 |
/**
|
|
| 2 |
*
|
|
| 3 |
* Copyright 2005 LogicBlaze, Inc.
|
|
| 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.logicblaze.lingo;
|
|
| 19 |
|
|
| 20 |
import org.springframework.remoting.support.RemoteInvocationFactory;
|
|
| 21 |
import org.springframework.remoting.support.RemoteInvocation;
|
|
| 22 |
import org.aopalliance.intercept.MethodInvocation;
|
|
| 23 |
|
|
| 24 |
import java.util.Map;
|
|
| 25 |
import java.util.HashMap;
|
|
| 26 |
import java.lang.reflect.Method;
|
|
| 27 |
|
|
| 28 |
/**
|
|
| 29 |
* A factory of remote invocation instances which includes the extra
|
|
| 30 |
* Lingo metadata.
|
|
| 31 |
*
|
|
| 32 |
* @version $Revision: 1.1 $
|
|
| 33 |
*/
|
|
| 34 |
public class LingoRemoteInvocationFactory implements RemoteInvocationFactory { |
|
| 35 |
private static final MethodMetadata DEFAULT_METHOD_METADATA = new MethodMetadata(false); |
|
| 36 |
|
|
| 37 |
private MetadataStrategy metadataStrategy;
|
|
| 38 |
private Map cache = new HashMap(); |
|
| 39 |
|
|
| 40 | 59 |
public LingoRemoteInvocationFactory(MetadataStrategy metadataStrategy) {
|
| 41 | 59 |
this.metadataStrategy = metadataStrategy;
|
| 42 |
} |
|
| 43 |
|
|
| 44 | 107 |
public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
|
| 45 | 107 |
MethodMetadata metadata = getMethodMetadata(methodInvocation); |
| 46 | 107 |
return new LingoInvocation(methodInvocation, metadata); |
| 47 |
} |
|
| 48 |
|
|
| 49 | 107 |
protected synchronized MethodMetadata getMethodMetadata(MethodInvocation methodInvocation) { |
| 50 | 107 |
Method method = methodInvocation.getMethod(); |
| 51 | 107 |
MethodMetadata answer = (MethodMetadata) cache.get(method); |
| 52 | 107 |
if (answer == null) { |
| 53 | 62 |
if (metadataStrategy == null) { |
| 54 |
// TODO we could use a singleton here
|
|
| 55 | 0 |
answer = DEFAULT_METHOD_METADATA; |
| 56 |
} |
|
| 57 |
else {
|
|
| 58 | 62 |
answer = metadataStrategy.getMethodMetadata(method); |
| 59 |
} |
|
| 60 | 62 |
cache.put(method, answer); |
| 61 |
} |
|
| 62 | 107 |
return answer;
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
} |
|
| 66 |
|
|
||||||||||