1616 */
1717package org .apache .solr .mcp .server .config ;
1818
19+ import java .util .concurrent .TimeUnit ;
1920import org .apache .solr .client .solrj .SolrClient ;
2021import org .apache .solr .client .solrj .impl .Http2SolrClient ;
2122import org .springframework .boot .context .properties .EnableConfigurationProperties ;
2223import org .springframework .context .annotation .Bean ;
2324import org .springframework .context .annotation .Configuration ;
2425
25- import java .util .concurrent .TimeUnit ;
26-
2726/**
2827 * Spring Configuration class for Apache Solr client setup and connection management.
29- *
30- * <p>This configuration class is responsible for creating and configuring the SolrJ client
31- * that serves as the primary interface for communication with Apache Solr servers. It handles
32- * URL normalization, connection parameters, and timeout configurations to ensure reliable
33- * connectivity for the MCP server operations.</p>
34- *
35- * <p><strong>Configuration Features:</strong></p>
28+ *
29+ * <p>This configuration class is responsible for creating and configuring the SolrJ client that
30+ * serves as the primary interface for communication with Apache Solr servers. It handles URL
31+ * normalization, connection parameters, and timeout configurations to ensure reliable connectivity
32+ * for the MCP server operations.
33+ *
34+ * <p><strong>Configuration Features:</strong>
35+ *
3636 * <ul>
37- * <li><strong>Automatic URL Normalization</strong>: Ensures proper Solr URL formatting</li>
38- * <li><strong>Connection Timeout Management</strong>: Configurable timeouts for reliability</li>
39- * <li><strong>Property Integration</strong>: Uses externalized configuration through properties</li>
40- * <li><strong>Production-Ready Defaults</strong>: Optimized timeout values for production use</li>
37+ * <li><strong>Automatic URL Normalization</strong>: Ensures proper Solr URL formatting
38+ * <li><strong>Connection Timeout Management</strong>: Configurable timeouts for reliability
39+ * <li><strong>Property Integration</strong>: Uses externalized configuration through properties
40+ * <li><strong>Production-Ready Defaults</strong>: Optimized timeout values for production use
4141 * </ul>
42- *
43- * <p><strong>URL Processing:</strong></p>
44- * <p>The configuration automatically normalizes Solr URLs to ensure proper communication:</p>
42+ *
43+ * <p><strong>URL Processing:</strong>
44+ *
45+ * <p>The configuration automatically normalizes Solr URLs to ensure proper communication:
46+ *
4547 * <ul>
46- * <li>Adds trailing slashes if missing</li>
47- * <li>Appends "/solr/" path if not present in the URL</li>
48- * <li>Handles various URL formats (with/without protocols, paths, etc.)</li>
48+ * <li>Adds trailing slashes if missing
49+ * <li>Appends "/solr/" path if not present in the URL
50+ * <li>Handles various URL formats (with/without protocols, paths, etc.)
4951 * </ul>
50- *
51- * <p><strong>Connection Parameters:</strong></p>
52+ *
53+ * <p><strong>Connection Parameters:</strong>
54+ *
5255 * <ul>
53- * <li><strong>Connection Timeout</strong>: 10 seconds (10,000ms) for establishing connections</li>
54- * <li><strong>Socket Timeout</strong>: 60 seconds (60,000ms) for read operations</li>
56+ * <li><strong>Connection Timeout</strong>: 10 seconds (10,000ms) for establishing connections
57+ * <li><strong>Socket Timeout</strong>: 60 seconds (60,000ms) for read operations
5558 * </ul>
56- *
57- * <p><strong>Configuration Example:</strong></p>
59+ *
60+ * <p><strong>Configuration Example:</strong>
61+ *
5862 * <pre>{@code
5963 * # application.properties
6064 * solr.url=http://localhost:8983
61- *
65+ *
6266 * # Results in normalized URL: http://localhost:8983/solr/
6367 * }</pre>
64- *
65- * <p><strong>Supported URL Formats:</strong></p>
68+ *
69+ * <p><strong>Supported URL Formats:</strong>
70+ *
6671 * <ul>
67- * <li>{@code http://localhost:8983} → {@code http://localhost:8983/solr/}</li>
68- * <li>{@code http://localhost:8983/} → {@code http://localhost:8983/solr/}</li>
69- * <li>{@code http://localhost:8983/solr} → {@code http://localhost:8983/solr/}</li>
70- * <li>{@code http://localhost:8983/solr/} → {@code http://localhost:8983/solr/} (unchanged)</li>
72+ * <li>{@code http://localhost:8983} → {@code http://localhost:8983/solr/}
73+ * <li>{@code http://localhost:8983/} → {@code http://localhost:8983/solr/}
74+ * <li>{@code http://localhost:8983/solr} → {@code http://localhost:8983/solr/}
75+ * <li>{@code http://localhost:8983/solr/} → {@code http://localhost:8983/solr/} (unchanged)
7176 * </ul>
7277 *
7378 * @version 0.0.1
7479 * @since 0.0.1
75- *
7680 * @see SolrConfigurationProperties
7781 * @see Http2SolrClient
7882 * @see org.springframework.boot.context.properties.EnableConfigurationProperties
@@ -87,44 +91,48 @@ public class SolrConfig {
8791
8892 /**
8993 * Creates and configures a SolrClient bean for Apache Solr communication.
90- *
91- * <p>This method serves as the primary factory for creating SolrJ client instances
92- * that are used throughout the application for all Solr operations. It performs
93- * automatic URL normalization and applies production-ready timeout configurations.</p>
94- *
95- * <p><strong>URL Normalization Process:</strong></p>
94+ *
95+ * <p>This method serves as the primary factory for creating SolrJ client instances that are
96+ * used throughout the application for all Solr operations. It performs automatic URL
97+ * normalization and applies production-ready timeout configurations.
98+ *
99+ * <p><strong>URL Normalization Process:</strong>
100+ *
96101 * <ol>
97- * <li><strong>Trailing Slash</strong>: Ensures URL ends with "/"</li>
98- * <li><strong>Solr Path</strong>: Appends "/solr/" if not already present</li>
99- * <li><strong>Validation</strong>: Checks for proper Solr endpoint format</li>
102+ * <li><strong>Trailing Slash</strong>: Ensures URL ends with "/"
103+ * <li><strong>Solr Path</strong>: Appends "/solr/" if not already present
104+ * <li><strong>Validation</strong>: Checks for proper Solr endpoint format
100105 * </ol>
101- *
102- * <p><strong>Connection Configuration:</strong></p>
106+ *
107+ * <p><strong>Connection Configuration:</strong>
108+ *
103109 * <ul>
104- * <li><strong>Connection Timeout</strong>: 10,000ms - Time to establish initial connection</li>
105- * <li><strong>Socket Timeout</strong>: 60,000ms - Time to wait for data/response</li>
110+ * <li><strong>Connection Timeout</strong>: 10,000ms - Time to establish initial connection
111+ * <li><strong>Socket Timeout</strong>: 60,000ms - Time to wait for data/response
106112 * </ul>
107- *
108- * <p><strong>Client Type:</strong></p>
109- * <p>Creates an {@code HttpSolrClient} configured for standard HTTP-based communication
110- * with Solr servers. This client type is suitable for both standalone Solr instances
111- * and SolrCloud deployments when used with load balancers.</p>
112- *
113- * <p><strong>Error Handling:</strong></p>
114- * <p>URL normalization is defensive and handles various input formats gracefully.
115- * Invalid URLs or connection failures will be caught during application startup
116- * or first usage, providing clear error messages for troubleshooting.</p>
117- *
118- * <p><strong>Production Considerations:</strong></p>
113+ *
114+ * <p><strong>Client Type:</strong>
115+ *
116+ * <p>Creates an {@code HttpSolrClient} configured for standard HTTP-based communication with
117+ * Solr servers. This client type is suitable for both standalone Solr instances and SolrCloud
118+ * deployments when used with load balancers.
119+ *
120+ * <p><strong>Error Handling:</strong>
121+ *
122+ * <p>URL normalization is defensive and handles various input formats gracefully. Invalid URLs
123+ * or connection failures will be caught during application startup or first usage, providing
124+ * clear error messages for troubleshooting.
125+ *
126+ * <p><strong>Production Considerations:</strong>
127+ *
119128 * <ul>
120- * <li>Timeout values are optimized for production workloads</li>
121- * <li>Connection pooling is handled by the HttpSolrClient internally</li>
122- * <li>Client is thread-safe and suitable for concurrent operations</li>
129+ * <li>Timeout values are optimized for production workloads
130+ * <li>Connection pooling is handled by the HttpSolrClient internally
131+ * <li>Client is thread-safe and suitable for concurrent operations
123132 * </ul>
124- *
133+ *
125134 * @param properties the injected Solr configuration properties containing connection URL
126135 * @return configured SolrClient instance ready for use in application services
127- *
128136 * @see Http2SolrClient.Builder
129137 * @see SolrConfigurationProperties#url()
130138 */
@@ -153,4 +161,4 @@ SolrClient solrClient(SolrConfigurationProperties properties) {
153161 .withIdleTimeout (SOCKET_TIMEOUT_MS , TimeUnit .MILLISECONDS )
154162 .build ();
155163 }
156- }
164+ }
0 commit comments