
| Key: |
SPR-1620
|
| Type: |
Improvement
|
| Status: |
Open
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
alberto manjarrez
|
| Votes: |
0
|
| Watchers: |
1
|
|
If you were logged in you would be able to see more operations.
|
|
|
| Virtual Machine: |
Sun JVM
- 1.4
|
| Platform: |
IBM WebSphere
- 5.1
|
|
A common pattern on a factory is to have a "discriminator" (argument) in the creation method. For example:
createInstance(int type);
createInstance(String type);
createInstance(Locale locale);
This is used to determine which specific instance needs to be created. Hence the API of the FactoryBean shoul be extended to support something like:
getObject(Object arg) or getObject(Object[] args)
This of course will have to be propagated to other interfaces and classes. For example:
the AbstractFactoryBean createInstance should be extended to support createInstance (Object arg);
or the BeanFactory getBean should be extended to support getBean(String id, Object arg);
|
|
Description
|
A common pattern on a factory is to have a "discriminator" (argument) in the creation method. For example:
createInstance(int type);
createInstance(String type);
createInstance(Locale locale);
This is used to determine which specific instance needs to be created. Hence the API of the FactoryBean shoul be extended to support something like:
getObject(Object arg) or getObject(Object[] args)
This of course will have to be propagated to other interfaces and classes. For example:
the AbstractFactoryBean createInstance should be extended to support createInstance (Object arg);
or the BeanFactory getBean should be extended to support getBean(String id, Object arg);
|
Show » |
|
The factory may create share instances or prototype.
Shared instance example:
- Consider a service to handle a request base on the Local (i.e. a different shared instance of the service should be located based on the Local)
- Another example is a handler service to handle a JMS message base on the message type or header
Prototype example:
- The creation of a translated data bean from the JMS Message type (i.e. JMS Message to domain object mapping. A new instance per received message)