View RSS Feed

Recent Blogs Posts

  1. Wiring Sets, Maps and Properties in Spring

    by , 11-16-2011 at 04:19 PM
    Similarly to lists, there are times when you will need to map to other types of collections. In this tip, I will outline what you need to do to wire sets, maps and properties. The key to remember is that you want to wire your bean to the same type that is being used in the class definition. So if your bean has a java.util.Set property to guarantee uniqueness in the collection, you want to use the same definition in the xml definition.

    So for example, if you want to use a java.util.Set, ...
  2. Spring Inner Beans

    by , 11-16-2011 at 04:15 PM
    Rather than configure beans separately and allow for Spring’s DI container to manage the injection of these beans into other beans, another means of wiring bean references is to embed a <bean> element directly in the <property> element. For example, the carDao property of the carService bean can be wired as follows:

    Java Code:
    <bean id="carService" class="com.acme.springexample.service.CarServiceImpl">
    <property name="carDao">
    ...

    Updated 11-30-2011 at 11:51 AM by Spring Framework

    Categories
    Dependency Injection , Bean
  3. Understanding the Difference Between Singleton vs. Prototyping of Spring Beans

    by , 11-16-2011 at 04:13 PM
    When you configure a new Spring beanBy default, all Spring beans are singletons. When the container dispenses a bean, it will always give the exact same instance of the bean. But sometimes you want the application context to return a unique instance for each time you request a specific bean. In this case, you would want to do is to define a prototype bean. When you define a prototype means that you define a blueprint of the bean. Every subsequent bean for this requested bean will be based on this ...