Commit 8715d2c6 by Johannes Edmeier

rework hazelcast support

Streamline the Hazelcast support with boot 1.3 and support storing events in hazelcast closes #113
parent 8b355ad7
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
<groupId>com.hazelcast</groupId> <groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId> <artifactId>hazelcast</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>${project.artifactId}</finalName> <finalName>${project.artifactId}</finalName>
......
...@@ -17,19 +17,30 @@ package de.codecentric.boot.admin; ...@@ -17,19 +17,30 @@ package de.codecentric.boot.admin;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import com.hazelcast.config.Config;
import com.hazelcast.config.EvictionPolicy;
import com.hazelcast.config.ListConfig;
import com.hazelcast.config.MapConfig;
import de.codecentric.boot.admin.config.EnableAdminServer; import de.codecentric.boot.admin.config.EnableAdminServer;
@Configuration @Configuration
@EnableAutoConfiguration @EnableAutoConfiguration
@EnableAdminServer @EnableAdminServer
@ImportResource({ "classpath:hazelcast-config.xml" })
public class SpringBootAdminApplication { public class SpringBootAdminApplication {
@Bean
public Config hazelcastConfig() {
return new Config().setProperty("hazelcast.jmx", "true")
.addMapConfig(new MapConfig("spring-boot-admin-application-store").setBackupCount(1)
.setEvictionPolicy(EvictionPolicy.NONE))
.addListConfig(new ListConfig("spring-boot-admin-application-store")
.setBackupCount(1).setMaxSize(1000));
}
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(SpringBootAdminApplication.class, args); SpringApplication.run(SpringBootAdminApplication.class, args);
} }
} }
...@@ -6,5 +6,3 @@ logging.file=/tmp/log.log ...@@ -6,5 +6,3 @@ logging.file=/tmp/log.log
spring.application.name=@pom.artifactId@ spring.application.name=@pom.artifactId@
spring.boot.admin.url=http://localhost:8081 spring.boot.admin.url=http://localhost:8081
hz.instance.name=Spring Boot Admin
\ No newline at end of file
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hz="http://www.hazelcast.com/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring-3.3.xsd">
<hz:config id="hazelcastConfig">
<hz:instance-name>${hz.instance.name}</hz:instance-name>
<hz:properties>
<hz:property name="hazelcast.jmx">true</hz:property>
</hz:properties>
<hz:map name="spring-boot-admin-application-store" backup-count="1" eviction-policy="NONE" />
</hz:config>
</beans>
\ No newline at end of file
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
<artifactId>spring-boot-configuration-processor</artifactId> <artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- Use Zuul WITHOUT Hystrix/Ribbon/Config Client --> <!-- Use Zuul WITHOUT Hystrix/Ribbon/Config Client -->
<dependency> <dependency>
<groupId>com.netflix.zuul</groupId> <groupId>com.netflix.zuul</groupId>
...@@ -48,14 +47,12 @@ ...@@ -48,14 +47,12 @@
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
</dependency> </dependency>
<!-- Optional Discovery Client --> <!-- Optional Discovery Client -->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId> <artifactId>spring-cloud-starter</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- Optional Hazelcast-Support --> <!-- Optional Hazelcast-Support -->
<dependency> <dependency>
<groupId>com.hazelcast</groupId> <groupId>com.hazelcast</groupId>
...@@ -69,12 +66,6 @@ ...@@ -69,12 +66,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
<optional>true</optional>
</dependency>
<!-- Test --> <!-- Test -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -17,63 +17,69 @@ package de.codecentric.boot.admin.config; ...@@ -17,63 +17,69 @@ package de.codecentric.boot.admin.config;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import com.hazelcast.config.Config;
import com.hazelcast.core.EntryAdapter; import com.hazelcast.core.EntryAdapter;
import com.hazelcast.core.EntryEvent; import com.hazelcast.core.EntryEvent;
import com.hazelcast.core.EntryListener; import com.hazelcast.core.EntryListener;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IList;
import com.hazelcast.core.IMap; import com.hazelcast.core.IMap;
import com.hazelcast.core.MapEvent; import com.hazelcast.core.MapEvent;
import com.hazelcast.map.listener.MapListener; import com.hazelcast.map.listener.MapListener;
import de.codecentric.boot.admin.event.ClientApplicationEvent;
import de.codecentric.boot.admin.event.RoutesOutdatedEvent; import de.codecentric.boot.admin.event.RoutesOutdatedEvent;
import de.codecentric.boot.admin.journal.store.HazelcastJournaledEventStore;
import de.codecentric.boot.admin.journal.store.JournaledEventStore;
import de.codecentric.boot.admin.model.Application; import de.codecentric.boot.admin.model.Application;
import de.codecentric.boot.admin.registry.store.ApplicationStore; import de.codecentric.boot.admin.registry.store.ApplicationStore;
import de.codecentric.boot.admin.registry.store.HazelcastApplicationStore; import de.codecentric.boot.admin.registry.store.HazelcastApplicationStore;
@Configuration @Configuration
@ConditionalOnClass({ Hazelcast.class }) @ConditionalOnSingleCandidate(HazelcastInstance.class)
@ConditionalOnProperty(prefix = "spring.boot.admin.hazelcast", name = "enabled", matchIfMissing = true) @ConditionalOnProperty(prefix = "spring.boot.admin.hazelcast", name = "enabled", matchIfMissing = true)
@AutoConfigureBefore(AdminServerWebConfiguration.class) @AutoConfigureBefore(AdminServerWebConfiguration.class)
@AutoConfigureAfter(HazelcastAutoConfiguration.class)
public class HazelcastStoreConfiguration { public class HazelcastStoreConfiguration {
@Value("${spring.boot.admin.hazelcast.map:spring-boot-admin-application-store}") @Value("${spring.boot.admin.hazelcast.application-store:spring-boot-admin-application-store}")
private String hazelcastMapName; private String hazelcastMapName;
@Value("${spring.boot.admin.hazelcast.event-store:spring-boot-admin-event-store}")
private String eventListName;
@Autowired @Autowired
private ApplicationEventPublisher publisher; private ApplicationEventPublisher publisher;
@Bean @Autowired
@ConditionalOnMissingBean private HazelcastInstance hazelcastInstance;
public Config hazelcastConfig() {
return new Config();
}
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingBean
public HazelcastInstance hazelcastInstance() {
return Hazelcast.newHazelcastInstance(hazelcastConfig());
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public ApplicationStore applicationStore() { public ApplicationStore applicationStore() {
IMap<String, Application> map = hazelcastInstance().getMap(hazelcastMapName); IMap<String, Application> map = hazelcastInstance.getMap(hazelcastMapName);
map.addIndex("name", false); map.addIndex("name", false);
map.addEntryListener((MapListener) entryListener(), false); map.addEntryListener((MapListener) entryListener(), false);
return new HazelcastApplicationStore(map); return new HazelcastApplicationStore(map);
} }
@Bean @Bean
@ConditionalOnMissingBean
public JournaledEventStore journaledEventStore() {
IList<ClientApplicationEvent> list = hazelcastInstance.getList(eventListName);
return new HazelcastJournaledEventStore(list);
}
@Bean
public EntryListener<String, Application> entryListener() { public EntryListener<String, Application> entryListener() {
return new EntryAdapter<String, Application>() { return new EntryAdapter<String, Application>() {
@Override @Override
...@@ -85,7 +91,6 @@ public class HazelcastStoreConfiguration { ...@@ -85,7 +91,6 @@ public class HazelcastStoreConfiguration {
public void onMapEvent(MapEvent event) { public void onMapEvent(MapEvent event) {
publisher.publishEvent(new RoutesOutdatedEvent()); publisher.publishEvent(new RoutesOutdatedEvent());
} }
}; };
} }
} }
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.codecentric.boot.admin.journal.store;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import com.hazelcast.core.IList;
import de.codecentric.boot.admin.event.ClientApplicationEvent;
/**
* Event-Store backed by a Hazelcast-list.
*
* @author Johannes Edmeier
*/
public class HazelcastJournaledEventStore implements JournaledEventStore {
private IList<ClientApplicationEvent> store;
public HazelcastJournaledEventStore(IList<ClientApplicationEvent> store) {
this.store = store;
}
@Override
public Collection<ClientApplicationEvent> findAll() {
ArrayList<ClientApplicationEvent> list = new ArrayList<>(store);
Collections.reverse(list);
return list;
}
@Override
public void store(ClientApplicationEvent event) {
store.add(event);
}
}
...@@ -15,12 +15,18 @@ ...@@ -15,12 +15,18 @@
"defaultValue": "true" "defaultValue": "true"
}, },
{ {
"name": "spring.boot.admin.hazelcast.map", "name": "spring.boot.admin.hazelcast.application-store",
"type": "java.lang.String", "type": "java.lang.String",
"description": "Name of backing Hazelcast-Map", "description": "Name of backing Hazelcast-Map for storing applications",
"defaultValue": "spring-boot-admin-application-store" "defaultValue": "spring-boot-admin-application-store"
}, },
{ {
"name": "spring.boot.admin.hazelcast.map",
"type": "java.lang.String",
"description": "Name of backing Hazelcast-List for storing the journal",
"defaultValue": "spring-boot-admin-event-store"
},
{
"name": "spring.boot.admin.discovery.enabled", "name": "spring.boot.admin.discovery.enabled",
"type": "java.lang.Boolean", "type": "java.lang.Boolean",
"description": "Enable Spring Cloud Discovery support.", "description": "Enable Spring Cloud Discovery support.",
......
...@@ -31,12 +31,17 @@ import org.springframework.boot.SpringApplication; ...@@ -31,12 +31,17 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext; import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
import org.springframework.boot.test.TestRestTemplate; import org.springframework.boot.test.TestRestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import com.hazelcast.config.Config;
import com.hazelcast.config.EvictionPolicy;
import com.hazelcast.config.ListConfig;
import com.hazelcast.config.MapConfig;
import de.codecentric.boot.admin.config.EnableAdminServer; import de.codecentric.boot.admin.config.EnableAdminServer;
import de.codecentric.boot.admin.model.Application; import de.codecentric.boot.admin.model.Application;
...@@ -50,8 +55,15 @@ public class AdminApplicationHazelcastTest { ...@@ -50,8 +55,15 @@ public class AdminApplicationHazelcastTest {
@Configuration @Configuration
@EnableAutoConfiguration @EnableAutoConfiguration
@EnableAdminServer @EnableAdminServer
@ImportResource("classpath:hazelcast-test.xml")
public static class TestAdminApplication { public static class TestAdminApplication {
@Bean
public Config hazelcastConfig() {
return new Config()
.addMapConfig(new MapConfig("spring-boot-admin-application-store")
.setBackupCount(1).setEvictionPolicy(EvictionPolicy.NONE))
.addListConfig(new ListConfig("spring-boot-admin-application-store")
.setBackupCount(1).setMaxSize(1000));
}
} }
private RestTemplate template = new TestRestTemplate(); private RestTemplate template = new TestRestTemplate();
...@@ -63,12 +75,10 @@ public class AdminApplicationHazelcastTest { ...@@ -63,12 +75,10 @@ public class AdminApplicationHazelcastTest {
System.setProperty("hazelcast.wait.seconds.before.join", "0"); System.setProperty("hazelcast.wait.seconds.before.join", "0");
instance1 = (EmbeddedWebApplicationContext) SpringApplication.run( instance1 = (EmbeddedWebApplicationContext) SpringApplication.run(
TestAdminApplication.class, TestAdminApplication.class,
new String[] { "--server.port=0", "--spring.jmx.enabled=false", new String[] { "--server.port=0", "--spring.jmx.enabled=false" });
"--spring.boot.admin.hazelcast.enabled=true" });
instance2 = (EmbeddedWebApplicationContext) SpringApplication.run( instance2 = (EmbeddedWebApplicationContext) SpringApplication.run(
TestAdminApplication.class, TestAdminApplication.class,
new String[] { "--server.port=0", "--spring.jmx.enabled=false", new String[] { "--server.port=0", "--spring.jmx.enabled=false" });
"--spring.boot.admin.hazelcast.enabled=true" });
} }
@After @After
...@@ -114,8 +124,8 @@ public class AdminApplicationHazelcastTest { ...@@ -114,8 +124,8 @@ public class AdminApplicationHazelcastTest {
private ResponseEntity<Application> getApp(String id, EmbeddedWebApplicationContext context) { private ResponseEntity<Application> getApp(String id, EmbeddedWebApplicationContext context) {
int port = context.getEmbeddedServletContainer().getPort(); int port = context.getEmbeddedServletContainer().getPort();
ResponseEntity<Application> getResponse = template.getForEntity("http://localhost:" + port ResponseEntity<Application> getResponse = template.getForEntity(
+ "/api/applications/" + id, Application.class); "http://localhost:" + port + "/api/applications/" + id, Application.class);
return getResponse; return getResponse;
} }
...@@ -130,8 +140,8 @@ public class AdminApplicationHazelcastTest { ...@@ -130,8 +140,8 @@ public class AdminApplicationHazelcastTest {
private ResponseEntity<Collection<Application>> getAppByName(String name, private ResponseEntity<Collection<Application>> getAppByName(String name,
EmbeddedWebApplicationContext context) { EmbeddedWebApplicationContext context) {
int port = context.getEmbeddedServletContainer().getPort(); int port = context.getEmbeddedServletContainer().getPort();
ResponseEntity<?> getResponse = template.getForEntity("http://localhost:" + port ResponseEntity<?> getResponse = template.getForEntity(
+ "/api/applications?name={name}", ApplicationList.class, "http://localhost:" + port + "/api/applications?name={name}", ApplicationList.class,
Collections.singletonMap("name", name)); Collections.singletonMap("name", name));
return (ResponseEntity<Collection<Application>>) getResponse; return (ResponseEntity<Collection<Application>>) getResponse;
} }
......
package de.codecentric.boot.admin.config; package de.codecentric.boot.admin.config;
import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.isA; import static org.hamcrest.CoreMatchers.isA;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
...@@ -12,15 +13,23 @@ import java.util.List; ...@@ -12,15 +13,23 @@ import java.util.List;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration;
import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration; import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration; import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
import org.springframework.boot.test.EnvironmentTestUtils; import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.cloud.client.discovery.noop.NoopDiscoveryClientAutoConfiguration; import org.springframework.cloud.client.discovery.noop.NoopDiscoveryClientAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import com.hazelcast.config.Config;
import de.codecentric.boot.admin.discovery.ApplicationDiscoveryListener; import de.codecentric.boot.admin.discovery.ApplicationDiscoveryListener;
import de.codecentric.boot.admin.journal.store.HazelcastJournaledEventStore;
import de.codecentric.boot.admin.journal.store.JournaledEventStore;
import de.codecentric.boot.admin.journal.store.SimpleJournaledEventStore;
import de.codecentric.boot.admin.notify.MailNotifier; import de.codecentric.boot.admin.notify.MailNotifier;
import de.codecentric.boot.admin.registry.store.ApplicationStore; import de.codecentric.boot.admin.registry.store.ApplicationStore;
import de.codecentric.boot.admin.registry.store.HazelcastApplicationStore; import de.codecentric.boot.admin.registry.store.HazelcastApplicationStore;
...@@ -63,42 +72,62 @@ public class AdminServerWebConfigurationTest { ...@@ -63,42 +72,62 @@ public class AdminServerWebConfigurationTest {
@Test @Test
public void simpleConfig() { public void simpleConfig() {
load("spring.boot.admin.hazelcast.enabled:false", load("spring.boot.admin.discovery.enabled:false");
"spring.boot.admin.discovery.enabled:false"); assertThat(context.getBean(ApplicationStore.class),
assertTrue(context.getBean(ApplicationStore.class) instanceof SimpleApplicationStore); is(instanceOf(SimpleApplicationStore.class)));
assertTrue(context.getBeansOfType(ApplicationDiscoveryListener.class).isEmpty()); assertTrue(context.getBeansOfType(ApplicationDiscoveryListener.class).isEmpty());
assertTrue(context.getBeansOfType(MailNotifier.class).isEmpty()); assertTrue(context.getBeansOfType(MailNotifier.class).isEmpty());
assertThat(context.getBean(JournaledEventStore.class),
is(instanceOf(SimpleJournaledEventStore.class)));
} }
@Test @Test
public void simpleConfig_mail() { public void simpleConfig_mail() {
load("spring.mail.host:localhost", "spring.boot.admin.hazelcast.enabled:false", load("spring.mail.host:localhost", "spring.boot.admin.discovery.enabled:false");
"spring.boot.admin.discovery.enabled:false"); assertThat(context.getBean(MailNotifier.class), is(instanceOf(MailNotifier.class)));
assertTrue(context.getBean(MailNotifier.class) instanceof MailNotifier);
} }
@Test @Test
public void hazelcastConfig() { public void hazelcastConfig() {
load("spring.boot.admin.hazelcast.enabled:true", load(TestHazelcastConfig.class, "spring.boot.admin.discovery.enabled:false");
"spring.boot.admin.discovery.enabled:false"); assertThat(context.getBean(ApplicationStore.class),
assertTrue(context.getBean(ApplicationStore.class) instanceof HazelcastApplicationStore); is(instanceOf(HazelcastApplicationStore.class)));
assertThat(context.getBean(JournaledEventStore.class),
is(instanceOf(HazelcastJournaledEventStore.class)));
assertTrue(context.getBeansOfType(ApplicationDiscoveryListener.class).isEmpty()); assertTrue(context.getBeansOfType(ApplicationDiscoveryListener.class).isEmpty());
} }
@Test @Test
public void discoveryConfig() { public void discoveryConfig() {
load("spring.boot.admin.hazelcast.enabled:false", load("spring.boot.admin.discovery.enabled:true");
"spring.boot.admin.discovery.enabled:true"); assertThat(context.getBean(ApplicationStore.class),
assertTrue(context.getBean(ApplicationStore.class) instanceof SimpleApplicationStore); is(instanceOf(SimpleApplicationStore.class)));
context.getBean(ApplicationDiscoveryListener.class); context.getBean(ApplicationDiscoveryListener.class);
} }
@Configuration
static class TestHazelcastConfig {
@Bean
Config config() {
return new Config();
}
}
private void load(String... environment) { private void load(String... environment) {
load(null, environment);
}
private void load(Class<?> config, String... environment) {
AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext(); AnnotationConfigWebApplicationContext applicationContext = new AnnotationConfigWebApplicationContext();
if (config != null) {
applicationContext.register(config);
}
applicationContext.register(PropertyPlaceholderAutoConfiguration.class); applicationContext.register(PropertyPlaceholderAutoConfiguration.class);
applicationContext.register(ServerPropertiesAutoConfiguration.class); applicationContext.register(ServerPropertiesAutoConfiguration.class);
applicationContext.register(NoopDiscoveryClientAutoConfiguration.class); applicationContext.register(NoopDiscoveryClientAutoConfiguration.class);
applicationContext.register(MailSenderAutoConfiguration.class); applicationContext.register(MailSenderAutoConfiguration.class);
applicationContext.register(HazelcastAutoConfiguration.class);
applicationContext.register(MailNotifierConfiguration.class); applicationContext.register(MailNotifierConfiguration.class);
applicationContext.register(HazelcastStoreConfiguration.class); applicationContext.register(HazelcastStoreConfiguration.class);
applicationContext.register(DiscoveryClientConfiguration.class); applicationContext.register(DiscoveryClientConfiguration.class);
......
...@@ -2,5 +2,4 @@ server.port=8080 ...@@ -2,5 +2,4 @@ server.port=8080
info.version=1.0.0 info.version=1.0.0
spring.application.name=spring-boot-admin-server-test spring.application.name=spring-boot-admin-server-test
spring.boot.admin.url=http://localhost:8080 spring.boot.admin.url=http://localhost:8080
spring.boot.admin.hazelcast.enabled=false
spring.boot.admin.discovery.enabled=false spring.boot.admin.discovery.enabled=false
\ No newline at end of file
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hz="http://www.hazelcast.com/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring-3.3.xsd">
<hz:config id="hazelcastConfig">
<hz:network port="5701">
<hz:join>
<hz:multicast enabled="false"/>
<hz:tcp-ip enabled="true">
<hz:member>localhost</hz:member>
</hz:tcp-ip>
</hz:join>
</hz:network>
</hz:config>
</beans>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment