Inject Spring context in a Servlet

Abstract Factory pattern with Spring lookup method
Spring Annotations scanning and activation
Secure applications with Spring Security

Scheduling With Spring 3.1

Some Java EE applications may needs to schedule tasks in order to get notified at certain times (i.e. every other Thursday, but only after 10 am and before 2 pm). This should be done in a consistent manner, using either a cron expression, an interval, or a rate. There are several way to do this, from EJB timer service introduced with EJB 3.1 to framework like Quartz.

Let’s assume that we are developing our application on Spring framework. Spring 3.0 debuts new support for configuring TaskExecutors and TaskSchedulers. This capability, coupled with the ability to schedule method execution using the @Scheduled annotation, makes Spring 3.0 very capable of meeting this challenge. The scheduling support works with a minimal of fuss: all you need are a method, an annotation, and to have switched on the scanner for annotations, in the simplest case.

Spring framework allows to easily configure an Hibernate datasource.
When using an ORM framework on its own, you have to configure its resource factory with its API. For Hibernate and JPA, you have to build a session factory and an entity manager factory from the native Hibernate API and JPA.
You have no choice but to manage these objects manually, without Spring’s support.Spring provides several factory beans for you to create a Hibernate session factory or a JPA entity manager factory as a singleton bean in the IoC container. These factories can be shared between multiple beans via dependency injection. Moreover, this allows the session factory and the entity manager factory to integrate with other Spring data access facilities, such as data sources and transaction managers.

SOAP Web Services using CXF with Spring
In this tutorial we are going to see how to implement SOAP Web Services using Spring Framework. In this example we’ll use a Contract-First approach. This approach encourages you to think of the service contract first, in terms of XML, using XML schema (.xsd) and WSDL. In this approach, you design the request and response messages for your service first. The messages are designed with XML, which is very good at representing complex data structures in a platform-and language-independent way. The next step is to implement this contract in a particular platform and programming language, in this case Java.There are two possible ways to develop a SOAP web service: application servers incorporating or stand-alone web application. In the first case a SOAP Engine or JAX-WS Runtime (like Axis, CXF or Metro) needs to be installed in the Application Server. A stand-alone application instead it’s not Application Server dependent and it can be deployed in a Servlet Container like Tomcat. Tomcat doesn’t support JAX-WS by itself, so we need to help it by embedding a JAX-WS runtime.What we will see is a stand-alone web application that expose a SOAP web service that calculate the sum of a list of integer.

If you want to learn more retro games news, read our magazine and subscribe to our newsletter.