Skip to content

Commit a01a809

Browse files
author
Yuriy Bezsonov
committed
feat(java-spring-ai-agents): improve HTTP client configuration and remove conditional annotations
1 parent 990fb4f commit a01a809

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

infra/scripts/deploy/java-spring-ai-agents/3-app.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,25 @@ EOF
167167
cat <<'EOF' > ~/environment/aiagent/src/main/java/com/example/agent/WeatherTools.java
168168
package com.example.agent;
169169
170+
import java.net.http.HttpClient;
170171
import java.util.List;
171172
import java.util.Map;
172173
import org.slf4j.Logger;
173174
import org.slf4j.LoggerFactory;
174175
import org.springframework.ai.tool.annotation.Tool;
175176
import org.springframework.ai.tool.annotation.ToolParam;
176177
import org.springframework.core.ParameterizedTypeReference;
178+
import org.springframework.http.client.JdkClientHttpRequestFactory;
177179
import org.springframework.web.client.RestClient;
178180
179181
class WeatherTools {
180182
181183
private static final Logger log = LoggerFactory.getLogger(WeatherTools.class);
182184
private static final ParameterizedTypeReference<Map<String, Object>> MAP_TYPE =
183185
new ParameterizedTypeReference<>() {};
184-
private final RestClient restClient = RestClient.create();
186+
private final RestClient restClient = RestClient.builder()
187+
.requestFactory(new JdkClientHttpRequestFactory(HttpClient.newHttpClient()))
188+
.build();
185189
186190
@Tool(description = """
187191
Get weather forecast for a city on a specific date.
@@ -343,7 +347,6 @@ EOF
343347
cat <<'EOF' > ~/environment/aiagent/src/main/java/com/example/agent/InvocationController.java
344348
package com.example.agent;
345349
346-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
347350
import org.springframework.http.MediaType;
348351
import org.springframework.security.core.annotation.AuthenticationPrincipal;
349352
import org.springframework.security.oauth2.jwt.Jwt;
@@ -352,7 +355,6 @@ import reactor.core.publisher.Flux;
352355
353356
@RestController
354357
@CrossOrigin(origins = "*")
355-
@ConditionalOnProperty(name = "app.controller.enabled", havingValue = "true", matchIfMissing = true)
356358
public class InvocationController {
357359
private final ChatService chatService;
358360

infra/scripts/deploy/java-spring-ai-agents/8-agentcore.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ sed -i '0,/<dependencies>/{/<dependencies>/a\
3535
<dependency>\
3636
<groupId>org.springaicommunity</groupId>\
3737
<artifactId>spring-ai-bedrock-agentcore-starter</artifactId>\
38-
<version>1.0.0-RC3</version>\
38+
<version>1.0.0-RC5</version>\
3939
</dependency>
4040
}' ~/environment/aiagent/pom.xml
4141
log_success "AgentCore dependencies added"
@@ -53,12 +53,10 @@ import java.util.Base64;
5353
import org.springaicommunity.agentcore.context.AgentCoreHeaders;
5454
import org.springaicommunity.agentcore.annotation.AgentCoreInvocation;
5555
import org.springaicommunity.agentcore.context.AgentCoreContext;
56-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
5756
import org.springframework.stereotype.Service;
5857
import reactor.core.publisher.Flux;
5958
6059
@Service
61-
@ConditionalOnProperty(name = "app.controller.enabled", havingValue = "false", matchIfMissing = false)
6260
public class InvocationService {
6361
private final ChatService chatService;
6462
private final ObjectMapper objectMapper = new ObjectMapper();
@@ -105,7 +103,6 @@ COPY --from=builder app.jar app.jar
105103
106104
USER 1000:1000
107105
EXPOSE 8080
108-
ENV APP_CONTROLLER_ENABLED=false
109106
110107
ENTRYPOINT ["java", "-jar", "/app.jar"]
111108
EOF

0 commit comments

Comments
 (0)