|
16 | 16 | */
|
17 | 17 | package org.apache.camel.example.springboot.infinispan;
|
18 | 18 |
|
19 |
| -import org.apache.camel.component.infinispan.remote.InfinispanRemoteComponent; |
20 |
| -import org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration; |
21 |
| - |
22 |
| -import org.infinispan.client.hotrod.RemoteCacheManager; |
23 |
| -import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; |
24 |
| -import org.slf4j.Logger; |
25 |
| -import org.slf4j.LoggerFactory; |
26 | 19 | import org.springframework.boot.SpringApplication;
|
27 | 20 | import org.springframework.boot.autoconfigure.SpringBootApplication;
|
28 |
| -import org.springframework.boot.context.properties.ConfigurationProperties; |
29 |
| -import org.springframework.context.annotation.Bean; |
30 |
| -import org.springframework.context.annotation.Configuration; |
31 |
| -import org.testcontainers.shaded.org.apache.commons.lang3.SystemUtils; |
32 |
| - |
33 |
| -import java.util.Properties; |
34 | 21 |
|
35 | 22 |
|
36 | 23 | // CHECKSTYLE:OFF
|
37 | 24 | @SpringBootApplication
|
38 | 25 | public class Application {
|
39 | 26 |
|
40 |
| - private static final Logger LOG = LoggerFactory.getLogger(Application.class); |
41 |
| - |
42 | 27 | /**
|
43 | 28 | * Main method to start the application.
|
44 | 29 | */
|
45 | 30 | public static void main(String[] args) {
|
46 | 31 | SpringApplication.run(Application.class, args);
|
47 | 32 | }
|
48 |
| - |
49 |
| - @Configuration |
50 |
| - @ConfigurationProperties(prefix = "infinispan") |
51 |
| - public class InfinispanConfiguration { |
52 |
| - |
53 |
| - private String host; |
54 |
| - |
55 |
| - private Integer port; |
56 |
| - |
57 |
| - private String username; |
58 |
| - |
59 |
| - private String password; |
60 |
| - |
61 |
| - private String serverName; |
62 |
| - |
63 |
| - protected ConfigurationBuilder getConfiguration() { |
64 |
| - ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); |
65 |
| - |
66 |
| - clientBuilder.forceReturnValues(true); |
67 |
| - |
68 |
| - |
69 |
| - clientBuilder.addServer().host(getHost()).port(getPort()); |
70 |
| - |
71 |
| - // add security info |
72 |
| - clientBuilder.security().authentication().username(getUsername()).password(getPassword()) |
73 |
| - .serverName(getServerName()).saslMechanism("DIGEST-MD5").realm("default"); |
74 |
| - if (SystemUtils.IS_OS_MAC) { |
75 |
| - Properties properties = new Properties(); |
76 |
| - properties.put("infinispan.client.hotrod.client_intelligence", "BASIC"); |
77 |
| - clientBuilder.withProperties(properties); |
78 |
| - } |
79 |
| - |
80 |
| - return clientBuilder; |
81 |
| - } |
82 |
| - |
83 |
| - @Bean(name = "infinispanRemoteComponent") |
84 |
| - public InfinispanRemoteComponent infinispanRemoteComponent() { |
85 |
| - InfinispanRemoteConfiguration infinispanRemoteConfiguration = new InfinispanRemoteConfiguration(); |
86 |
| - infinispanRemoteConfiguration.setHosts(getHost() + ":" + getPort()); |
87 |
| - infinispanRemoteConfiguration.setUsername(getUsername()); |
88 |
| - infinispanRemoteConfiguration.setPassword(getPassword()); |
89 |
| - |
90 |
| - RemoteCacheManager cacheContainer = new RemoteCacheManager(getConfiguration().build()); |
91 |
| - infinispanRemoteConfiguration.setCacheContainer(cacheContainer); |
92 |
| - |
93 |
| - InfinispanRemoteComponent component = new InfinispanRemoteComponent(); |
94 |
| - component.setConfiguration(infinispanRemoteConfiguration); |
95 |
| - return component; |
96 |
| - } |
97 |
| - |
98 |
| - public String getHost() { |
99 |
| - return host; |
100 |
| - } |
101 |
| - |
102 |
| - public void setHost(final String host) { |
103 |
| - this.host = host; |
104 |
| - } |
105 |
| - |
106 |
| - public Integer getPort() { |
107 |
| - return port; |
108 |
| - } |
109 |
| - |
110 |
| - public void setPort(final Integer port) { |
111 |
| - this.port = port; |
112 |
| - } |
113 |
| - |
114 |
| - public String getUsername() { |
115 |
| - return username; |
116 |
| - } |
117 |
| - |
118 |
| - public void setUsername(final String username) { |
119 |
| - this.username = username; |
120 |
| - } |
121 |
| - |
122 |
| - public String getPassword() { |
123 |
| - return password; |
124 |
| - } |
125 |
| - |
126 |
| - public void setPassword(final String password) { |
127 |
| - this.password = password; |
128 |
| - } |
129 |
| - |
130 |
| - public String getServerName() { |
131 |
| - return serverName; |
132 |
| - } |
133 |
| - |
134 |
| - public void setServerName(final String serverName) { |
135 |
| - this.serverName = serverName; |
136 |
| - } |
137 |
| - } |
138 |
| - |
139 | 33 | }
|
140 | 34 | // CHECKSTYLE:ON
|
0 commit comments