EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.item.jms]

COVERAGE SUMMARY FOR SOURCE FILE [JmsMethodArgumentsKeyGenerator.java]

nameclass, %method, %block, %line, %
JmsMethodArgumentsKeyGenerator.java100% (1/1)100% (2/2)73%  (33/45)67%  (6/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JmsMethodArgumentsKeyGenerator100% (1/1)100% (2/2)73%  (33/45)67%  (6/9)
getKey (Object []): Object 100% (1/1)71%  (30/42)62%  (5/8)
JmsMethodArgumentsKeyGenerator (): void 100% (1/1)100% (3/3)100% (1/1)

1/*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17package org.springframework.batch.item.jms;
18 
19import javax.jms.JMSException;
20import javax.jms.Message;
21 
22import org.springframework.batch.item.UnexpectedInputException;
23import org.springframework.retry.interceptor.MethodArgumentsKeyGenerator;
24 
25/**
26 * A {@link MethodArgumentsKeyGenerator} for JMS 
27 * 
28 * @author Dave Syer
29 * 
30 */
31public class JmsMethodArgumentsKeyGenerator implements MethodArgumentsKeyGenerator {
32 
33        /**
34         * If the message is a {@link Message} then returns the JMS message ID.
35         * Otherwise just return the first argument.
36         * 
37         * @see org.springframework.retry.interceptor.MethodArgumentsKeyGenerator#getKey(Object[])
38         * 
39         * @throws UnexpectedInputException if the JMS id cannot be determined from
40         * a JMS Message
41         * @throws IllegalArgumentException if the arguments are empty
42         */
43    @Override
44        public Object getKey(Object[] items) {
45                for (Object item : items) {
46                        if (item instanceof Message) {
47                                try {
48                                        return ((Message) item).getJMSMessageID();
49                                }
50                                catch (JMSException e) {
51                                        throw new UnexpectedInputException("Could not extract message ID", e);
52                                }
53                        }
54                }
55                if (items.length == 0) {
56                        throw new IllegalArgumentException(
57                                        "Method parameters are empty.  The key generator cannot determine a unique key.");
58                }
59                return items[0];
60        }
61 
62}

[all classes][org.springframework.batch.item.jms]
EMMA 2.0.5312 (C) Vladimir Roubtsov