Class OpenSearchClientFactory

java.lang.Object
org.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>
org.craftercms.search.opensearch.spring.OpenSearchClientFactory
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<org.opensearch.client.opensearch.OpenSearchClient>, org.springframework.beans.factory.InitializingBean

public class OpenSearchClientFactory extends org.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>
Implementation of AbstractFactoryBean to create instances of OpenSearchClient
Since:
4.0.0
Author:
joseross
  • Field Details

    • serverUrls

      protected final String[] serverUrls
      List of OpenSearch urls
    • username

      protected String username
      The username for OpenSearch
    • password

      protected String password
      The password for OpenSearch
    • connectTimeout

      protected int connectTimeout
      The connection timeout in milliseconds
    • socketTimeout

      protected int socketTimeout
      The socket timeout in milliseconds
    • threadCount

      protected int threadCount
      The number of threads to use
    • socketKeepAlive

      protected boolean socketKeepAlive
      Indicates if socket keep alive should be enabled
    • maxTotalConnections

      protected int maxTotalConnections
      The maximum number of connections
    • maxConnectionsPerRoute

      protected int maxConnectionsPerRoute
      The maximum number of connections per route
  • Constructor Details

  • Method Details

    • setUsername

      public void setUsername(String username)
    • setPassword

      public void setPassword(String password)
    • setConnectTimeout

      public void setConnectTimeout(int connectTimeout)
    • setSocketTimeout

      public void setSocketTimeout(int socketTimeout)
    • setThreadCount

      public void setThreadCount(int threadCount)
    • setSocketKeepAlive

      public void setSocketKeepAlive(boolean socketKeepAlive)
    • setMaxConnectionsPerRoute

      public void setMaxConnectionsPerRoute(int maxConnectionsPerRoute)
    • setMaxTotalConnections

      public void setMaxTotalConnections(int maxTotalConnections)
    • createClient

      public static org.opensearch.client.opensearch.OpenSearchClient createClient(String[] serverUrls, String username, String password, int connectTimeout, int socketTimeout, int threadCount, boolean socketKeepAlive, int maxTotalConnections, int maxConnectionsPerRoute) throws URISyntaxException
      Creates an OpenSearchClient instance
      Parameters:
      serverUrls - array of OpenSearch server URLs
      username - the username
      password - the password
      connectTimeout - connection timeout
      socketTimeout - socket timeout
      threadCount - number of threads
      socketKeepAlive - indicates if socket keep alive should be enabled
      maxTotalConnections - maximum total connections
      maxConnectionsPerRoute - maximum connections per route
      Returns:
      the OpenSearchClient instance
      Throws:
      URISyntaxException
    • getObjectType

      public Class<?> getObjectType()
      Specified by:
      getObjectType in interface org.springframework.beans.factory.FactoryBean<org.opensearch.client.opensearch.OpenSearchClient>
      Specified by:
      getObjectType in class org.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>
    • createInstance

      protected @NonNull org.opensearch.client.opensearch.OpenSearchClient createInstance() throws URISyntaxException
      Specified by:
      createInstance in class org.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>
      Throws:
      URISyntaxException
    • destroyInstance

      protected void destroyInstance(@Nullable org.opensearch.client.opensearch.OpenSearchClient instance) throws Exception
      Overrides:
      destroyInstance in class org.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>
      Throws:
      Exception