File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes spring - declarative collections Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Other Application Frameworks
Reply Bookmark "spring - declarative collections " Watch "spring - declarative collections " New topic
Author

spring - declarative collections

Abdul Aleem
Greenhorn

Joined: Jul 19, 2002
Posts: 19
Hi All,
I am new to spring, we have a requirement
that we would like to change our java data
structures declaratively (configurable).

i.e , we have implemented data feeds, queues
using PriorityQueue, Synchronized Hashmaps, vectors
etc

will spring framework give me an option to inject (instantiate)
these collections classes dynamically.
I mean , if we need to change to PriorityBlockingQueue, and change
Hashmaps to hashtable and vectors to Synchronized ArrayLists

i would greatly appreciate if someone can give some pointers
if this is supported by spring framework.

Many thanks,
Abdul Aleem
Junilu Lacar
Ranch Hand

Joined: Feb 26, 2001
Posts: 3008
Spring can help ease the pain. Here are some suggestions:

1. Program to interfaces; use interfaces or abstract types for your method/constructor parameters. Spring can inject any type of object as long as it is assignment compatible with the receiving method/constructor parameter's type. If you do this, it will be easier to switch out implementations.

2. Take advantage of Spring's built-in collection injection support for injecting lists, maps, sets, and properties.

3. If things start to get ugly, try using the Adapter pattern. Create an Adapter that can accept one or more of the natively supported collections and then inject the adapter into the target class. The target class then uses the adapter to get whatever type of collection it needs. The adapter does the transformation from simple collection to custom collection. This should probably be considered as a last resort. Strive to keep your code simple using 1 & 2 above.


Junilu
[How to Ask Questions] [How to Answer Questions] [MiH]
 
 
subject: spring - declarative collections
 
Threads others viewed
ArrayList Vector Collections Array
Hashtable vs. HashMap
forEach nested loop
about B&S database file
Collection- Fast Retrieval
IntelliJ Java IDE