@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> }
/** * Creates a MapAttributeConfig with the given attribute and ordered setting. * <p> * Name may begin with an ascii letter [A-Za-z] or digit [0-9] and may contain ascii letters [A-Za-z], digits [0-9] * or underscores later on. * * @param name the name given to an attribute that is going to be extracted * @param extractor full class name of the extractor used to extract the value of the attribute * @see #setName(String) * @see #setExtractor(String) */ public MapAttributeConfig(String name, String extractor) { setName(name); setExtractor(extractor); }
/** * Creates a MapAttributeConfig with the given attribute and ordered setting. * <p> * Name may begin with an ascii letter [A-Za-z] or digit [0-9] and may contain ascii letters [A-Za-z], digits [0-9] * or underscores later on. * * @param name the name given to an attribute that is going to be extracted * @param extractor full class name of the extractor used to extract the value of the attribute * @see #setName(String) * @see #setExtractor(String) */ public MapAttributeConfig(String name, String extractor) { setName(name); setExtractor(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(); }