[Geoserver-devel] GetMapFormats beaning

Jesse Eichar wrote:

Hey Justin,

So there have been a few hurdles.

1. getFormats is static and is called by WMSCapsTransformer. WMSCapsTransformer is not a bean so obviously can't get the required information... However it can get access to the WMS object. Unfortunately, the WMS is not application context aware so it doesn't know the context either...

Yes unfortunatley GeoServer is plagued with static convenience methods and the evil singleton.

Solutions:
1. WMS can be made context aware.
Advantages: GetMapResponse is created with a WMS as its parameter and WMSCapTransformer has access to one as well so they would not need to be changed very much.
Disadvantages: WMS is tied to the context. WMSCapsTransformer is either required to create a new GetMapResponse object each time it satisfies a request. Unless it caches them, which would also work.

2. Capabilites is a ApplicationContextAware bean and is responsible for making the WMSCapsTransformer object so it could pass in the ApplicationContext when it constructs the object. GetMap would do the same for the GetMapResponse object.

Advantages: Minimal changes to existing code.
Disadvantages: WMSCapsTransformer is either required to create a new GetMapResponse object each time it satisfies a request.

I'm going to implement #2 I think seems better.

I agree here. Make the Capabilities + GetMap beans ApplicationContextAware and then just pass the context via constructor to any created objects. Seems like a good solution to me. Great work Jesse!!

-Justin

Jesse

--
Justin Deoliveira
The Open Planning Project
jdeolive@anonymised.com