@Bean public HazelcastInstance hazelcastInstance() { MapAttributeConfig attributeConfig = new MapAttributeConfig() .setName(HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE) .setExtractor(PrincipalNameExtractor.class.getName()); Config config = new Config(); config.getMapConfig(HazelcastSessionRepository.DEFAULT_SESSION_MAP_NAME) // <2> .addMapAttributeConfig(attributeConfig) .addMapIndexConfig(new MapIndexConfig( HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE, false)); return Hazelcast.newHazelcastInstance(config); // <3> }
@Override public IdentifiedDataSerializable createNew(Integer arg) { return new MapAttributeConfig(); } };
@Override public IdentifiedDataSerializable createNew(Integer arg) { return new MapAttributeConfig(); } };
private void mapAttributesHandle(Node n, MapConfig mapConfig) { for (Node extractorNode : childElements(n)) { if ("attribute".equals(cleanNodeName(extractorNode))) { NamedNodeMap attrs = extractorNode.getAttributes(); String extractor = getTextContent(attrs.getNamedItem("extractor")); String name = getTextContent(extractorNode); mapConfig.addMapAttributeConfig(new MapAttributeConfig(name, extractor)); } } }
private void mapAttributesHandle(Node n, MapConfig mapConfig) { for (Node extractorNode : childElements(n)) { if ("attribute".equals(cleanNodeName(extractorNode))) { NamedNodeMap attrs = extractorNode.getAttributes(); String extractor = getTextContent(attrs.getNamedItem("extractor")); String name = getTextContent(extractorNode); mapConfig.addMapAttributeConfig(new MapAttributeConfig(name, extractor)); } } }
public static MapAttributeConfig decode(ClientMessage clientMessage) { MapAttributeConfig config = new MapAttributeConfig(); config.setName(clientMessage.getStringUtf8()); config.setExtractor(clientMessage.getStringUtf8()); return config; }
public static MapAttributeConfig decode(ClientMessage clientMessage) { MapAttributeConfig config = new MapAttributeConfig(); config.setName(clientMessage.getStringUtf8()); config.setExtractor(clientMessage.getStringUtf8()); return config; }
public static MapAttributeConfig decode(ClientMessage clientMessage) { MapAttributeConfig config = new MapAttributeConfig(); config.setName(clientMessage.getStringUtf8()); config.setExtractor(clientMessage.getStringUtf8()); return config; }
public static void main(String[] args) throws ParseException { MapAttributeConfig mapAttributeConfig = new MapAttributeConfig(); mapAttributeConfig.setName("limbName"); mapAttributeConfig.setExtractor("com.test.portable.LimbNameExtractor"); MapConfig mapConfig = new MapConfig(); mapConfig.setName("people"); mapConfig.addMapAttributeConfig(mapAttributeConfig); Config config = new Config(); config.getSerializationConfig().addPortableFactory(PersonFactory.FACTORY_ID, new PersonFactory()); config.addMapConfig(mapConfig); HazelcastInstance hz = Hazelcast.newHazelcastInstance(config); IMap<Integer, Person> map = hz.getMap("people"); map.put(1, new Person("Georg", limb("left-leg"), limb("right-leg"))); map.put(2, new Person("Peter", limb("left-hand"), limb("right-hand"))); map.put(3, new Person("Hans", limb("left-finger"), limb("right-finger"))); map.put(4, new Person("Stefanie", limb("left-arm"), limb("right-arm"))); // we're using a custom attribute 'limbName' which is provided by the 'LimbNameExtractor' Set<Person> people = (Set<Person>) map.values(Predicates.equal("limbName", "left-arm")); System.out.println("People: " + people); Hazelcast.shutdownAll(); }