Stopping the threads

Starting a thread is very easy in java, after you create it you need to call the method start(), for example:

where MyRunnable is a class implementing the Runnable interface overidden the method run().
Continue reading “Stopping the threads”

How to set a default method to running code on the creation or destruction of a bean

In the post Executing code on the creation or destruction of a bean in Spring I explain three ways to execute code on the creation or destruction of a Bean in Spring.
With two of these ways you can set the execution of a specific custom method:

  • with the annotations @PostConstruct and @PreDestroy
  • configuring the properties init-method and destroy-method

There is a very convenient way in the case that more beans have methods with the same name to be executed on their creation and destruction, i.e. you can specify a default method for all the beans.
Continue reading “How to set a default method to running code on the creation or destruction of a bean”

MessageSource in Spring 3

The MessageSource interface supports the parameterization and internationalization of messages and provides 2 implementations:

  1. ResourceBundleMessageSource, built on top of the standard ResourceBundle
  2. ReloadableResourceBundleMessageSource, being able to reload message definitions without restarting the VM

The following is an example of ResourceBundleMessageSource to get messages in the specified language in Spring 3.
Continue reading “MessageSource in Spring 3”