1 /*
2 * Copyright 2006-2010 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 package org.springframework.batch.item.mail;
17
18 import org.springframework.mail.MailException;
19 import org.springframework.mail.MailMessage;
20
21 /**
22 * This class is used to handle errors that occur when email messages are unable
23 * to be sent.
24 *
25 * @author Dan Garrette
26 * @author Dave Syer
27 *
28 * @since 2.1
29 */
30 public interface MailErrorHandler {
31
32 /**
33 * This method will be called for each message that failed sending in the
34 * chunk. If the failed message is needed by the handler it will need to be
35 * downcast according to its runtime type. If an exception is thrown from
36 * this method, then it will propagate to the caller.
37 *
38 * @param message the failed message
39 * @param exception the exception that caused the failure
40 * @throws MailException if the exception cannot be handled
41 */
42 public void handle(MailMessage message, Exception exception) throws MailException;
43
44 }