001/* 002 * Copyright 2006-2010 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.springframework.batch.sample.domain.mail.internal; 017 018import java.util.Date; 019 020import org.springframework.batch.item.ItemProcessor; 021import org.springframework.batch.sample.domain.mail.User; 022import org.springframework.mail.SimpleMailMessage; 023 024/** 025 * @author Dan Garrette 026 * @author Dave Syer 027 * 028 * @since 2.1 029 */ 030public class UserMailItemProcessor implements 031 ItemProcessor<User, SimpleMailMessage> { 032 033 /** 034 * @see org.springframework.batch.item.ItemProcessor#process(java.lang.Object) 035 */ 036 @Override 037 public SimpleMailMessage process( User user ) throws Exception { 038 SimpleMailMessage message = new SimpleMailMessage(); 039 message.setTo( user.getEmail() ); 040 message.setFrom( "[email protected]" ); 041 message.setSubject( user.getName() + "'s Account Info" ); 042 message.setSentDate( new Date() ); 043 message.setText( "Hello " + user.getName() ); 044 return message; 045 } 046}