|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2019 the original author or authors. |
| 2 | + * Copyright 2014-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package docs.http;
|
18 | 18 |
|
19 |
| -import com.hazelcast.config.Config; |
20 |
| -import com.hazelcast.config.MapAttributeConfig; |
21 |
| -import com.hazelcast.config.MapIndexConfig; |
22 |
| -import com.hazelcast.config.SerializerConfig; |
23 |
| -import com.hazelcast.core.Hazelcast; |
24 |
| -import com.hazelcast.core.HazelcastInstance; |
| 19 | +// import com.hazelcast.config.AttributeConfig; |
| 20 | +// import com.hazelcast.config.Config; |
| 21 | +// import com.hazelcast.config.IndexConfig; |
| 22 | +// import com.hazelcast.config.IndexType; |
| 23 | +// import com.hazelcast.config.SerializerConfig; |
| 24 | +// import com.hazelcast.core.Hazelcast; |
| 25 | +// import com.hazelcast.core.HazelcastInstance; |
| 26 | +// |
| 27 | +// import org.springframework.context.annotation.Bean; |
| 28 | +// import org.springframework.context.annotation.Configuration; |
| 29 | +// import org.springframework.session.MapSession; |
| 30 | +// import org.springframework.session.hazelcast.HazelcastIndexedSessionRepository; |
| 31 | +// import org.springframework.session.hazelcast.HazelcastSessionSerializer; |
| 32 | +// import org.springframework.session.hazelcast.PrincipalNameExtractor; |
| 33 | +// import |
| 34 | +// org.springframework.session.hazelcast.config.annotation.web.http.EnableHazelcastHttpSession; |
25 | 35 |
|
26 |
| -import org.springframework.context.annotation.Bean; |
27 |
| -import org.springframework.context.annotation.Configuration; |
28 |
| -import org.springframework.session.MapSession; |
29 |
| -import org.springframework.session.hazelcast.HazelcastIndexedSessionRepository; |
30 |
| -import org.springframework.session.hazelcast.HazelcastSessionSerializer; |
31 |
| -import org.springframework.session.hazelcast.PrincipalNameExtractor; |
32 |
| -import org.springframework.session.hazelcast.config.annotation.web.http.EnableHazelcastHttpSession; |
33 |
| - |
34 |
| -//tag::config[] |
35 |
| -@EnableHazelcastHttpSession // <1> |
36 |
| -@Configuration |
37 |
| -public class HazelcastHttpSessionConfig { |
38 |
| - |
39 |
| - @Bean |
40 |
| - public HazelcastInstance hazelcastInstance() { |
41 |
| - Config config = new Config(); |
42 |
| - MapAttributeConfig attributeConfig = new MapAttributeConfig() |
43 |
| - .setName(HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE) |
44 |
| - .setExtractor(PrincipalNameExtractor.class.getName()); |
45 |
| - config.getMapConfig(HazelcastIndexedSessionRepository.DEFAULT_SESSION_MAP_NAME) // <2> |
46 |
| - .addMapAttributeConfig(attributeConfig).addMapIndexConfig( |
47 |
| - new MapIndexConfig(HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE, false)); |
48 |
| - SerializerConfig serializerConfig = new SerializerConfig(); |
49 |
| - serializerConfig.setImplementation(new HazelcastSessionSerializer()).setTypeClass(MapSession.class); |
50 |
| - config.getSerializationConfig().addSerializerConfig(serializerConfig); // <3> |
51 |
| - return Hazelcast.newHazelcastInstance(config); // <4> |
52 |
| - } |
53 |
| - |
54 |
| -} |
| 36 | +// tag::config[] |
| 37 | +// @EnableHazelcastHttpSession // <1> |
| 38 | +// @Configuration |
| 39 | +// public class HazelcastHttpSessionConfig { |
| 40 | +// |
| 41 | +// @Bean |
| 42 | +// public HazelcastInstance hazelcastInstance() { |
| 43 | +// Config config = new Config(); |
| 44 | +// AttributeConfig attributeConfig = new AttributeConfig() |
| 45 | +// .setName(HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE) |
| 46 | +// .setExtractorClassName(PrincipalNameExtractor.class.getName()); |
| 47 | +// config.getMapConfig(HazelcastIndexedSessionRepository.DEFAULT_SESSION_MAP_NAME) // <2> |
| 48 | +// .addAttributeConfig(attributeConfig).addIndexConfig( |
| 49 | +// new IndexConfig(IndexType.HASH, |
| 50 | +// HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE)); |
| 51 | +// SerializerConfig serializerConfig = new SerializerConfig(); |
| 52 | +// serializerConfig.setImplementation(new |
| 53 | +// HazelcastSessionSerializer()).setTypeClass(MapSession.class); |
| 54 | +// config.getSerializationConfig().addSerializerConfig(serializerConfig); // <3> |
| 55 | +// return Hazelcast.newHazelcastInstance(config); // <4> |
| 56 | +// } |
| 57 | +// |
| 58 | +// } |
55 | 59 | // end::config[]
|
0 commit comments