[Geoserver-devel] [JIRA] (GEOS-10364) Duplicate bean definitions in gwc spring context config files

Gabriel Roldan created an issue

GeoServer / TaskGEOS-10364

Duplicate bean definitions in gwc spring context config files

Issue Type:

TaskTask

Assignee:

Gabriel Roldan

Created:

24/Jan/22 2:10 AM

Priority:

MediumMedium

Reporter:

Gabriel Roldan

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

Add Comment

Add Comment

Get Jira notifications on your phone! Download the Jira Cloud app for Android or iOS


This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100189-sha1:399499b)

Atlassian logo