6.8 Spring integration
For a Restlet or a
The
What this means is that Spring will create the instance of the class, and honor the Spring-related annotations on it. Spring will however not manage the complete life-cycle of the object, so e.g. @Destroy annotations will not be honored.
The most useful is Spring's Autowired annotation. Below is an example of its usage. The system will automatically look up a bean in your Spring container of the 'MessageService' type. If there would be multiple of those, then there are additional annotations to select the correct implementation. See the Spring documentation for more information.
import org.springframework.beans.factory.annotation.Autowired
public class MessageResource {
private MessageService messageService
@Autowired
void setMessageService(MessageService messageService) {
this.messageService = messageService;
}
}
Previous