There are 5 duplicate bean definitions in gs-gwc:
grep "<bean " -Rh|grep id|sed 's/ //g'|sed 's/\t//g'|cut -d'"' -f2|sort|uniq -c|grep -v "1 "
2 gwcFacade
2 gwcGeoServervConfigPersister
2 gwcInitializer
2 gwcTransactionListener
2 gwcWMSExtendedCapabilitiesProvider
Also, the following beans are duplicates, they do exactly the same, unnecessarily multiplying the number of AOP method interceptors:
<bean id="gwcServiceWMSInterceptorEnabledCheck" class="org.geoserver.gwc.config.GWCServiceEnablementInterceptor">
<bean id="gwcServiceTMSInterceptorEnabledCheck" class="org.geoserver.gwc.config.GWCServiceEnablementInterceptor">
<bean id="gwcWMTSServiceInterceptorEnabledCheck" class="org.geoserver.gwc.config.GWCServiceEnablementInterceptor">
<bean id="gwcServiceVEInterceptorEnabledCheck" class="org.geoserver.gwc.config.GWCServiceEnablementInterceptor">
<bean id="gwcServiceKMLInterceptorEnabledCheck" class="org.geoserver.gwc.config.GWCServiceEnablementInterceptor">
<bean id="gwcServiceGMapsterceptorEnabledCheck" class="org.geoserver.gwc.config.GWCServiceEnablementInterceptor">
<bean id="gwcServiceMGMapsterceptorEnabledCheck" class="org.geoserver.gwc.config.GWCServiceEnablementInterceptor">
Ratioale being GWCServiceEnablementInterceptor checks delegates to gwcFacade.isServiceEnabled(service) , as shown bellow, and it’s not parameterized, so all those beans are the same:
final org.geowebcache.service.Service service = (Service) invocation.getThis();
boolean serviceEnabled;
if (service.getPathName().equals("wmts")) {
serviceEnabled = geoServer.getService(WMTSInfo.class).isEnabled();
} else {
serviceEnabled = gwcFacade.isServiceEnabled(service);
}
Proposal is:
-
Remove duplicate bean definitions
-
Replace all GWCServiceEnablementInterceptor beans by a single one
-
Refactor bean locations, several beans are defined in applicationContext.xml , which in turn imports geowebcache-servlet.xml and geowebcache-geoserver-context.xml , while geowebcache-servlet.xml imports all the regular GWC context files. Since there are 106 unique bean definitions in total, it’s hard to reason what goes where, so I’d like to have applicationContext.xml be just like:
<import resource="geowebcache-servlet.xml" />
<import resource="geowebcache-geoserver-context.xml" />
<import resource="geowebcache-geoserver-wms-integration.xml" />
<import resource="geowebcache-geoserver-wmts-integration.xml" />
instead of mixing up geoserver specific beans across applicationContext.xml and geowebcache-geoserver-context.xml
|