<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(repository.gwt.qualified_abstract_application_name) %>;

@javax.annotation.Generated( "Domgen" )
@SuppressWarnings( { "PMD.ConstructorCallsOverridableMethod" } )
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings( { "STT_STRING_PARSING_A_FIELD", "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS", "PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" } )
public abstract class <%= repository.gwt.abstract_application_name %><I extends <%= repository.gwt.qualified_abstract_dagger_component_name %>>
{
<% if repository.keycloak? -%>
  private final org.realityforge.gwt.keycloak.Keycloak _keycloak;
<% end -%>
  private final String _serverUrl;

  protected <%= repository.gwt.abstract_application_name %>(<% if repository.keycloak? -%> @javax.annotation.Nonnull final String keycloakClient <% end -%>)
  {
    final String applicationURL = com.google.gwt.core.client.GWT.getModuleBaseURL();
    _serverUrl = applicationURL.substring( 0, applicationURL.indexOf( '/', applicationURL.indexOf( "://" ) + 3 ) );
<% if repository.keycloak? -%>
    _keycloak = new org.realityforge.gwt.keycloak.Keycloak( keycloakClient, applicationURL + ".keycloak/" + keycloakClient + "/keycloak.json" );
    _keycloak.setListener( newKeycloakListener() );
<% end -%>
  }

  public String getServerUrl()
  {
    return _serverUrl;
  }

  @javax.annotation.Nullable
  protected abstract I getInjector();

  @javax.annotation.Nonnull
  protected final I ensureInjector()
  {
    final I injector = getInjector();
    assert null != injector;
    return injector;
  }

  public void init()
  {
<% if repository.gwt_rpc? -%>
    initGwtRpcServices();
<% end -%>
<% if repository.keycloak? -%>
    getKeycloak().init();
<% else -%>
    start();
<% end -%>
  }

  public void start()
  {
    preStart();
<% if repository.arez? -%>
    setupArezLocator();
<% end -%>
<% if repository.appcache? -%>
    setupAppCache();
<% end -%>
<% if repository.keycloak? && repository.imit? -%>
    setupReplicantToken();
<% end -%>
    setupUncaughtExceptionHandler();
    prepareServices();
    prepareUI();
    postStart();
  }

  private void setupUncaughtExceptionHandler()
  {
    com.google.gwt.core.client.GWT.setUncaughtExceptionHandler( new com.google.gwt.core.client.GWT.UncaughtExceptionHandler()
    {
      @Override
      public void onUncaughtException( final Throwable e )
      {
        <%= repository.gwt.abstract_application_name %>.this.onUncaughtException( e );
      }
    } );
  }
<% if repository.arez? -%>

  private void setupArezLocator()
  {
    arez.Arez.context().registerLocator( ensureInjector().getLocator() );
  }
<% end -%>
<% if repository.appcache? -%>

  private void setupAppCache()
  {
    if ( null != elemental2.dom.DomGlobal.applicationCache && elemental2.dom.DomGlobal.document.getElementsByTagName( "html" ).item( 0 ).hasAttribute( "manifest" ) )
    {
      elemental2.dom.DomGlobal.applicationCache.addEventListener( "updateready", e -> {
          if ( elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.UNCACHED &&
               elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.CHECKING &&
               elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.DOWNLOADING )
          {
            elemental2.dom.DomGlobal.applicationCache.swapCache();
          }
          onAppcacheUpdateReadyEvent();
      } );
      if ( elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.UNCACHED &&
           elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.CHECKING &&
           elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.DOWNLOADING )
      {
        elemental2.dom.DomGlobal.applicationCache.update();
      }
    }
  }

  protected abstract void onAppcacheUpdateReadyEvent();
<% end -%>

  protected abstract void postStart();

  protected abstract void preStart();

  protected void prepareServices()
  {
<% if repository.imit? -%>
    replicant.WebStorageCacheService.install();
    elemental2.dom.DomGlobal.window.addEventListener( "pagehide", e -> replicant.Replicant.context().deactivate(), true );
<% end -%>
  }

  protected abstract void prepareUI();

  protected void onUncaughtException( @javax.annotation.Nonnull final Throwable e )
  {
    if( <%= repository.gwt.qualified_debug_config_name %>.EMIT_RAW_UNCAUGHT_EXCEPTIONS && com.google.gwt.core.client.GWT.isScript() && com.google.gwt.core.client.GWT.isProdMode() )
    {
      logThrowable( e  );
    }
<% if repository.iris_audit? -%>
    final iris.audit.client.ClientExceptionAuditHelper helper = getClientExceptionAuditHelper();
    if ( null != helper )
    {
      helper.auditClientException( e, e.getMessage() );
    }
<% end -%>
  }
<% if repository.gwt_rpc? -%>

  protected void initGwtRpcServices()
  {
<% if repository.keycloak? -%>
    <%= repository.gwt_rpc.qualified_rpc_services_dagger_module_name %>.setKeycloak( getKeycloak() );
<% end -%>
    <%= repository.gwt_rpc.qualified_rpc_services_dagger_module_name %>.setBaseURL( com.google.gwt.core.client.GWT.getModuleBaseURL() );
<% if repository.iris_audit? -%>
    iris.audit.client.ioc.AuditGwtRpcServicesDaggerModule.setBaseURL( com.google.gwt.core.client.GWT.getModuleBaseURL() );
<% if repository.keycloak? -%>
    iris.audit.client.ioc.AuditGwtRpcServicesDaggerModule.setKeycloak( getKeycloak() );
<% end -%>
<% end -%>
<% if repository.imit? -%>
<% repository.imit.remote_datasources.select{|ds| ds.gwt_rpc_enabled? }.each do |ds| -%>
    <%= ds.base_package %>.client.ioc.<%= ds.name %>GwtRpcServicesDaggerModule.setBaseURL( getServerUrl() + "/<%= Reality::Naming.underscore(ds.name) %>/" );
<% if repository.keycloak? && ds.keycloak_enabled? -%>
    <%= ds.base_package %>.client.ioc.<%= ds.name %>GwtRpcServicesDaggerModule.setKeycloak( getKeycloak() );
<% end -%>
<% end -%>
<% end -%>
<% if repository.berk? -%>
    iris.berk.client.ioc.BerkGwtRpcServicesDaggerModule.setBaseURL( com.google.gwt.core.client.GWT.getModuleBaseURL() );
<% if repository.keycloak? -%>
    iris.berk.client.ioc.BerkGwtRpcServicesDaggerModule.setKeycloak( getKeycloak() );
<% end -%>
<% end -%>
  }
<% end -%>
<% if repository.iris_audit? -%>

  @javax.annotation.Nullable<commit_msg>getModuleBaseURL is always returning /XXX even when the app is deployed to /, at least in our prod environments. Change to use getHostPageBaseURL instead, which behaves as desired<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(repository.gwt.qualified_abstract_application_name) %>;

@javax.annotation.Generated( "Domgen" )
@SuppressWarnings( { "PMD.ConstructorCallsOverridableMethod" } )
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings( { "STT_STRING_PARSING_A_FIELD", "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS", "PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" } )
public abstract class <%= repository.gwt.abstract_application_name %><I extends <%= repository.gwt.qualified_abstract_dagger_component_name %>>
{
<% if repository.keycloak? -%>
  private final org.realityforge.gwt.keycloak.Keycloak _keycloak;
<% end -%>
  private final String _serverUrl;

  protected <%= repository.gwt.abstract_application_name %>(<% if repository.keycloak? -%> @javax.annotation.Nonnull final String keycloakClient <% end -%>)
  {
    final String applicationURL = com.google.gwt.core.client.GWT.getHostPageBaseURL();
    _serverUrl = applicationURL.substring( 0, applicationURL.indexOf( '/', applicationURL.indexOf( "://" ) + 3 ) );
<% if repository.keycloak? -%>
    _keycloak = new org.realityforge.gwt.keycloak.Keycloak( keycloakClient, applicationURL + ".keycloak/" + keycloakClient + "/keycloak.json" );
    _keycloak.setListener( newKeycloakListener() );
<% end -%>
  }

  public String getServerUrl()
  {
    return _serverUrl;
  }

  @javax.annotation.Nullable
  protected abstract I getInjector();

  @javax.annotation.Nonnull
  protected final I ensureInjector()
  {
    final I injector = getInjector();
    assert null != injector;
    return injector;
  }

  public void init()
  {
<% if repository.gwt_rpc? -%>
    initGwtRpcServices();
<% end -%>
<% if repository.keycloak? -%>
    getKeycloak().init();
<% else -%>
    start();
<% end -%>
  }

  public void start()
  {
    preStart();
<% if repository.arez? -%>
    setupArezLocator();
<% end -%>
<% if repository.appcache? -%>
    setupAppCache();
<% end -%>
<% if repository.keycloak? && repository.imit? -%>
    setupReplicantToken();
<% end -%>
    setupUncaughtExceptionHandler();
    prepareServices();
    prepareUI();
    postStart();
  }

  private void setupUncaughtExceptionHandler()
  {
    com.google.gwt.core.client.GWT.setUncaughtExceptionHandler( new com.google.gwt.core.client.GWT.UncaughtExceptionHandler()
    {
      @Override
      public void onUncaughtException( final Throwable e )
      {
        <%= repository.gwt.abstract_application_name %>.this.onUncaughtException( e );
      }
    } );
  }
<% if repository.arez? -%>

  private void setupArezLocator()
  {
    arez.Arez.context().registerLocator( ensureInjector().getLocator() );
  }
<% end -%>
<% if repository.appcache? -%>

  private void setupAppCache()
  {
    if ( null != elemental2.dom.DomGlobal.applicationCache && elemental2.dom.DomGlobal.document.getElementsByTagName( "html" ).item( 0 ).hasAttribute( "manifest" ) )
    {
      elemental2.dom.DomGlobal.applicationCache.addEventListener( "updateready", e -> {
          if ( elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.UNCACHED &&
               elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.CHECKING &&
               elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.DOWNLOADING )
          {
            elemental2.dom.DomGlobal.applicationCache.swapCache();
          }
          onAppcacheUpdateReadyEvent();
      } );
      if ( elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.UNCACHED &&
           elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.CHECKING &&
           elemental2.dom.DomGlobal.applicationCache.status != elemental2.dom.ApplicationCache.DOWNLOADING )
      {
        elemental2.dom.DomGlobal.applicationCache.update();
      }
    }
  }

  protected abstract void onAppcacheUpdateReadyEvent();
<% end -%>

  protected abstract void postStart();

  protected abstract void preStart();

  protected void prepareServices()
  {
<% if repository.imit? -%>
    replicant.WebStorageCacheService.install();
    elemental2.dom.DomGlobal.window.addEventListener( "pagehide", e -> replicant.Replicant.context().deactivate(), true );
<% end -%>
  }

  protected abstract void prepareUI();

  protected void onUncaughtException( @javax.annotation.Nonnull final Throwable e )
  {
    if( <%= repository.gwt.qualified_debug_config_name %>.EMIT_RAW_UNCAUGHT_EXCEPTIONS && com.google.gwt.core.client.GWT.isScript() && com.google.gwt.core.client.GWT.isProdMode() )
    {
      logThrowable( e  );
    }
<% if repository.iris_audit? -%>
    final iris.audit.client.ClientExceptionAuditHelper helper = getClientExceptionAuditHelper();
    if ( null != helper )
    {
      helper.auditClientException( e, e.getMessage() );
    }
<% end -%>
  }
<% if repository.gwt_rpc? -%>

  protected void initGwtRpcServices()
  {
<% if repository.keycloak? -%>
    <%= repository.gwt_rpc.qualified_rpc_services_dagger_module_name %>.setKeycloak( getKeycloak() );
<% end -%>
    <%= repository.gwt_rpc.qualified_rpc_services_dagger_module_name %>.setBaseURL( com.google.gwt.core.client.GWT.getHostPageBaseURL() );
<% if repository.iris_audit? -%>
    iris.audit.client.ioc.AuditGwtRpcServicesDaggerModule.setBaseURL( com.google.gwt.core.client.GWT.getHostPageBaseURL() );
<% if repository.keycloak? -%>
    iris.audit.client.ioc.AuditGwtRpcServicesDaggerModule.setKeycloak( getKeycloak() );
<% end -%>
<% end -%>
<% if repository.imit? -%>
<% repository.imit.remote_datasources.select{|ds| ds.gwt_rpc_enabled? }.each do |ds| -%>
    <%= ds.base_package %>.client.ioc.<%= ds.name %>GwtRpcServicesDaggerModule.setBaseURL( getServerUrl() + "/<%= Reality::Naming.underscore(ds.name) %>/" );
<% if repository.keycloak? && ds.keycloak_enabled? -%>
    <%= ds.base_package %>.client.ioc.<%= ds.name %>GwtRpcServicesDaggerModule.setKeycloak( getKeycloak() );
<% end -%>
<% end -%>
<% end -%>
<% if repository.berk? -%>
    iris.berk.client.ioc.BerkGwtRpcServicesDaggerModule.setBaseURL( com.google.gwt.core.client.GWT.getHostPageBaseURL() );
<% if repository.keycloak? -%>
    iris.berk.client.ioc.BerkGwtRpcServicesDaggerModule.setKeycloak( getKeycloak() );
<% end -%>
<% end -%>
  }
<% end -%>
<% if repository.iris_audit? -%>

  @javax.annotation.Nullable
{'fraction_non_alphanumeric': 0.14600742804085423, 'fraction_numerical': 0.0032497678737233053, 'mean_word_length': 4.0, 'pattern_counts': {'":': 2, '<': 119, '<?xml version=': 0, '>': 123, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3517685', 'n_tokens_mistral': 4537, 'n_tokens_neox': 4280, 'n_words': 627}