Spring Tutorials

pring Integration 2
Spring Integration 2: Integrating RabbitMQ and Web Service
Spring Integration 2: Integrating a JDBC and WS System

Spring REST
Spring 3: REST Web Service Provider and Client Tutorial (Part 1)
Spring 3: REST Web Service Provider and Client Tutorial (Part 2)

Spring Data and MongoDB
Spring Data – MongoDB (Revision for 1.0.0.M2)
Spring Data – MongoDB Tutorial (1.0.0.M1)

Spring MVC 3 and Apache POI
Spring 3 – Apache POI – Hibernate: Creating an Excel Report Tutorial

Spring MVC 3 and jQuery
Spring MVC 3 and jQuery Integration Tutorial

Spring MVC 3 and DWR
Spring MVC 3 and DWR 3 Integration Tutorial

Spring MVC 3 and MongoDB
Spring MVC 3: Using a Document-Oriented Database – MongoDB

Spring Scheduling
Spring 3 – Quartz Scheduling
Spring 3 – Task Scheduling via Annotations: @Scheduled, @Async
Spring 3 – Task Scheduling via “scheduled-tasks” Element

Spring LDAP
Spring Security – MVC: Using an Embedded LDAP Server
Spring Security – MVC: Using an LDAP Authentication Provider
LDAP – Apache Directory Studio: A Basic Tutorial

Spring MVC 3 and Apache Tiles 2
Spring MVC 3 – Tiles 2 Integration Tutorial

Spring MVC
Spring 3 MVC: Using @ModelAttribute in Your JSPs

Spring WS: WS-Security
Spring WS 2: Client-side WS-Security Using XWSS
Spring WS 2: Client-side WS-Security Using WSS4J
Spring-WS 2: WS-Security Using XWSS
Spring-WS 2: WS-Security Using WSS4J

Spring WS: XPath
Spring WS: Handling XML With XPath Using Jaxp13XPathTemplate
Spring WS: Handling XML With XPath Using JaxenXPathTemplate
Spring WS: Handling XML With XPath Using XPathExpression

Spring WS: Client
Spring MVC 3 – Accessing web services using JAX-WS
Spring WS – MVC: Implementing a Client Tutorial

Spring WS: Provider
Spring WS 2 and Spring 3 MVC Integration Tutorial
Spring WS: A Tutorial Using the Latest 2.0.0 RC2 Build

Spring MVC 3 and JDBC
Spring 3 MVC – JDBC Integration Tutorial

Spring MVC 3 and Hibernate Tutorials Series
Spring JPA: Many-To-One Association: Using Hibernate as the JPA Vendor
Spring JPA: One-To-Many Association: Using Hibernate as the JPA Vendor
Spring – Hibernate: Many-To-One Association – Explicitly Specify Join Table, Cascade, and Fetch
Spring – Hibernate: One-To-Many Association – Explicitly Specify Join Table, Cascade, and Fetch
Spring – Hibernate: Many-To-One Association
Spring – Hibernate: One-To-Many Association
Spring MVC 3, Hibernate Annotations, MySQL Integration Tutorial
Spring MVC 3, Hibernate Annotations, HSQLDB Integration Tutorial

Spring MVC 3 and Jasper
Spring MVC 3 – Jasper: How to Use JasperReportsMultiFormatView
Spring 3 MVC – Jasper: Using Two Sub-reports with Distinct Data Sources Tutorial
Spring 3 MVC – Jasper Integration Tutorial Without the View Support
Spring 3 MVC – Jasper: Sub-reports Using Two Data Sources Tutorial
Spring 3 MVC – Jasper: Sub-reports Tutorial
Spring 3 MVC – Jasper Integration Tutorial

Spring 3 and GWT
Spring and GWT: Security via Spring Security
Spring and GWT Integration using Maven and GWTHandler (Part 2)
Spring and GWT Integration using Maven and GWTHandler (Part 1)

Spring MVC 3 and DynamicJasper
Spring 3 – DynamicJasper – Hibernate Tutorial: Concatenating a DynamicReport
Spring 3 – DynamicJasper – Hibernate Tutorial: Concatenating a Subreport
Spring 3 – DynamicJasper – Hibernate Tutorial: Using Plain List
Spring 3 – DynamicJasper – Hibernate Tutorial: Using JRDataSource
Spring 3 – DynamicJasper – Hibernate Tutorial: Using HQL Query
Spring 3 MVC – DynamicJasper Integration Tutorial

Spring Security 3 and CAPTCHA
Spring Security 3: Integrating reCAPTCHA Service

Spring Security 3: OpenID
Spring Security 3 – OpenID with Javascript OpenID Selector
Spring Security 3 – OpenID Login with Google Provider
Spring Security 3 – OpenID Login with myOpenID Provider

Spring Security 3: ACL
Spring Security 3: Full ACL Tutorial (Part 4)
Spring Security 3: Full ACL Tutorial (Part 3)
Spring Security 3: Full ACL Tutorial (Part 2)
Spring Security 3: Full ACL Tutorial (Part 1)
Spring Security: Simple ACL using Expression-Based Access Control (Part 2)
Spring Security: Simple ACL using Expression-Based Access Control (Part 1)

Spring Security 3: Expressions
Spring Security 3 – MVC: Using Native Expression-Based Annotation Tutorial
Spring Security 3 – MVC: Using @Secured Annotation Tutorial

Spring MVC 3 and Spring Security
Spring JPA: Many-To-One Association: Using Hibernate as the JPA Vendor
Spring Security – MVC: Implementing a Single Entry Filter Tutorial
Spring Security – MVC: Querying the SessionRegistry
Spring Security 3 – MVC: Using a Simple User-Service Tutorial
Spring Security 3 – MVC Integration: Using A Custom Authentication Manager
Spring Security 3 – MVC Integration Tutorial (Part 2)
Spring Security 3 – MVC Integration Tutorial (Part 1)

Spring MVC 3 and jqGrid
Spring 3: Dynamic MVC using jqGrid and MongoDB
jqGrid and Spring 3 MVC Integration Tutorial

Blogger
How to customize your Google ads placement and position them in a custom Blogger template.
How to apply a custom Blogger Template

Spring, Quartz and JavaMail Tutrial

Quartz is a job scheduling framework which is used to schedule the jobs to be executed on the specified time schedule.JavaMail is an API to send/recieve emails from Java Applications.

Spring has integration points to integrate Quartz and JavaMail which makes easy to use those APIs. Lets create a small demo application to show how to integrate Spring + Quartz + JavaMail.

Our application is to send birthday wishes emails to friends everyday at 6 AM.

Download Tutrial

Quartz integration with JSP,Servlet

Quartz integration with Spring>

How To send Email with attachment in java with spring

1-add Emailtemplate.vm to class path of java i mean src/main/java

<html>
<body>
<h3 >${subject} </h3>
<div>   ${messageBody} </div>
<h3>File ID=${FileID}    <br> Provider ID=${ProviderID}
</h3>
</body>
</html>

2-then add dependency in pom file for volicity


<dependency>
<groupId>maven</groupId>
<artifactId>velocity</artifactId>
<version>1.5-20060721.044818</version>
<exclusions>
<exclusion>
<groupId>geronimo-spec</groupId>
<artifactId>geronimo-spec-javamail</artifactId>

</exclusion>

<exclusion>
<groupId>geronimo-spec</groupId>
<artifactId>geronimo-spec-jms</artifactId>

</exclusion>

</exclusions>
</dependency>

3- add bean in root context for java mail sender and one also for volicity
<!–email sender –>
<bean id=”mailSender”
p:host=”mail.bookdepository.co.uk” p:port=”27″>

<property name=”username” value=”shady.ragab” />
<property name=”password” value=”User2010″ />

</bean>

<!– velocity template –>
<bean id=”velocityEngine”
class=”org.springframework.ui.velocity.VelocityEngineFactoryBean”>
<property name=”velocityProperties”>
<value>
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
</value>
</property>
</bean>

4- service

@Service
public class MailServiceImpl implements MailService {

	@Autowired
	JavaMailSender mailSender;
	@Autowired
	VelocityEngine velocityEngine;

	public void send(final String from, final String[] to, final String[] cc, final String[] bcc,

			final String subject, final String messageBody,final NotificationBean notification)

			throws MessagingException {

		  final MimeMessagePreparator preparator = new MimeMessagePreparator()
		  {
		         public void prepare(MimeMessage mimeMessage) throws Exception {
		            MimeMessageHelper message = new MimeMessageHelper(mimeMessage,true);
		            message.setSubject(subject);
		            message.setTo(to);
		            message.setFrom(from); // could be parameterized...
		            message.setBcc(bcc);
		            message.setCc(cc);
		            Map model = new HashMap();
		            model.put("subject",subject);
		            model.put("messageBody",messageBody);

		            Listtemp= (List) notification.getNotificationParamsCollection();
		            for (NotificationParam param : temp) {
		            	System.out.println(param.getId().getKey()+"  "+ param.getValue());
				    if(param.getId().getKey().equals("File ID"))
					     model.put("FileID",param.getValue());
					 if(param.getId().getKey().equals("Provider ID"))
						  model.put("ProviderID",param.getValue());

					}

		            String text = VelocityEngineUtils.mergeTemplateIntoString(
				               velocityEngine, new ClassPathResource("Emailtemplate.vm").getPath(), model);
		            message.setText(text, true);

		            byte[]attachdata="this is testing file".getBytes();
		            InputStreamSource source= new ByteArrayResource(attachdata);
		            message.addAttachment("test.txt", source,"text/plain");
		            /*if(notification.getAttachmentFileName()!=null){
		            message.addAttachment(notification.getAttachmentFileName().concat(notification.getMimeType().getExtension()),
		            		new ByteArrayDataSource(notification.getAttachment(), notification.getMimeType().getMimeType()));
		            }*/

		         }
		      };

		      new Thread(){
		    	  public void run(){
		    		  mailSender.send(preparator);
		    	  }
		      }.start();

	}

}

Modular Java: Creating Flexible Applications with OSGi and Spring

The secret weapon for attacking complexity in any project is to break it down into smaller, cohesive, and more easily digestible pieces. With Modular Java, you can easily develop applications that are more flexible, testable, maintainable, and comprehensible.

Modular Java is a pragmatic guide to developing modular applications using OSGi, the framework for dynamic modularity in Java, and Spring Dynamic Modules, an OSGi extension to the Spring Framework. You’ll start with the basics but quickly ramp up, creating loosely coupled modules that publish and consume services, and you’ll see how to compose them into larger applications. Along the way, you’ll apply what you learn as you build a complete web application that is made up of several OSGi modules, using Spring-DM to wire those modules together.

Modular Java is filled with tips and tricks that will make you a more proficient OSGi and Spring-DM developer. Equipped with the know-how gained from this book, you’ll be able to develop applications that are more robust and agile.

click here to download