@CacheEntryCreated public void entryCreated(CacheEntryCreatedEvent<String, String> event) { // We are only interested in the post event if (!event.isPre()) System.out.printf("Created %s\n", event.getKey()); }
private void cacheEntryCreated(CacheEntryCreatedEvent event) { if (! (event.getKey() instanceof String) || ! (event.getValue() instanceof String[])) { return; } String httpSessionId = (String) event.getKey(); String[] value = (String[]) event.getValue(); String ssoId = value[0]; String principal = value[1]; LOG.tracev("cacheEntryCreated {0}:{1}", httpSessionId, ssoId); this.idMapper.map(ssoId, principal, httpSessionId); }
@CacheEntryCreated public void cacheEntryCreated(CacheEntryCreatedEvent<String, Serializable> event) { eventReceived(event.getKey(), event.getValue()); }
@CacheEntryCreated public void dataAdded(CacheEntryCreatedEvent event) { if (log.isTraceEnabled()) { if (event.isPre()) { log.trace("Going to add new entry " + event.getKey() + " to the cache " + event.getCache().getName()); } else { log.trace("Added new entry " + event.getKey() + " to the cache " + event.getCache().getName()); } } }
private void cacheEntryCreated(CacheEntryCreatedEvent event) { if (! (event.getKey() instanceof String)) { return; } String httpSessionId = (String) event.getKey(); if (idMapper.hasSession(httpSessionId)) { // Ignore local events generated by remote store LOG.tracev("IGNORING cacheEntryCreated {0}", httpSessionId); return; } String[] value = ssoCache.get((String) httpSessionId); String ssoId = value[0]; String principal = value[1]; LOG.tracev("cacheEntryCreated {0}:{1}", httpSessionId, ssoId); this.idMapper.map(ssoId, principal, httpSessionId); }
/** * Each new item added in the {@link KarmaCache} will trigger a event that will add/update the karma points for the given key * in the persistence layer {@link KarmaRepository} * @param event {@link CacheEntryCreatedEvent} */ @CacheEntryCreated public void entryCreated(CacheEntryCreatedEvent event) { if (event.getValue() != null) { try { karma.updateOrCreateKarma(new Karma(event.getKey().toString().split(":")[0], (int) event.getValue())); } catch (final Exception e) { e.printStackTrace(); } } }
public ObserverAssertion hasEntryCreatedEvent(String key) { assertEquals(getNonEmptyListOfEvents(CacheEntryCreatedEvent.class).get(0).getKey(), key); return this; }
@CacheEntryCreated public void scheduled( final CacheEntryCreatedEvent<ScheduleKey, Map> e ) { if ( e == null ) { logger.error( "[FATAL]The infinispan cache created event for indy schedule manager is null.", new NullPointerException( "CacheEntryCreatedEvent is null" ) ); return; } if ( !e.isPre() ) { final ScheduleKey expiredKey = e.getKey(); final Map expiredContent = e.getValue(); if ( expiredKey != null && expiredContent != null ) { logger.debug( "Expiration Created: {}", expiredKey ); final String type = (String) expiredContent.get( ScheduleManager.JOB_TYPE ); final String data = (String) expiredContent.get( ScheduleManager.PAYLOAD ); fireEvent( eventDispatcher, new SchedulerScheduleEvent( type, data ) ); } } }
public ObserverAssertion hasEntryCreatedEvent(String key) { assertEquals(getNonEmptyListOfEvents(CacheEntryCreatedEvent.class).get(0).getKey(), key); return this; }
@CacheEntryCreated public void observeAdd(CacheEntryCreatedEvent<String, String> event) { if (event.isPre()) return; log.infof("Cache entry %s added in cache %s", event.getKey(), event.getCache()); }
@CacheEntryCreated public void observeCreate(CacheEntryCreatedEvent<Object, Object> event) { if (event.isPre()) { return; } if (this.toBeUpdated != null) { this.toBeUpdated.entryCreated(event.getKey(), this.containerName, this.cacheName, event.isOriginLocal()); } }
@CacheEntryCreated public void created(CacheEntryCreatedEvent<KeyValuePair<String, Class>, Boolean> e) { if (!e.isOriginLocal() && !e.isPre() && e.getValue()) { handleClusterRegistryRegistration(e.getKey().getValue()); } }
@CacheEntryCreated public void created(CacheEntryCreatedEvent<KeyValuePair<String, Class>, Boolean> e) { if (!e.isOriginLocal() && !e.isPre() && e.getValue()) { handleClusterRegistryRegistration(e.getKey().getValue()); } }
@CacheEntryCreated public void created(CacheEntryCreatedEvent<String, Object> event) { if (!event.isPre()) { Object object; // Try optimized version if available if (isNewInfinispan) { object = event.getValue(); } else { String id = event.getKey(); object = event.getCache().get(id); } if (object != null) { if (object instanceof CachedRealm) { CachedRealm realm = (CachedRealm) object; realmLookup.put(realm.getName(), realm.getId()); log.tracev("Realm added realm={0}", realm.getName()); } } } }
public void testFilters() { n.notifyCacheEntryCreated("reject", "v1", null, true, ctx, null); n.notifyCacheEntryCreated("reject", "v1", null, false, ctx, null); assert !cl.isReceivedPost(); assert !cl.isReceivedPre(); assert cl.getInvocationCount() == 0; n.notifyCacheEntryCreated("accept", "v1", null, true, ctx, null); n.notifyCacheEntryCreated("accept", "v1", null, false, ctx, null); assert cl.isReceivedPost(); assert cl.isReceivedPre(); assert cl.getInvocationCount() == 2; assert cl.getEvents().get(0).getCache() == mockCache; assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_CREATED; assert ((CacheEntryCreatedEvent) cl.getEvents().get(0)).getKey().equals("accept"); assert ((CacheEntryCreatedEvent) cl.getEvents().get(0)).getValue() == null; assert cl.getEvents().get(1).getCache() == mockCache; assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_CREATED; assert ((CacheEntryCreatedEvent) cl.getEvents().get(1)).getKey().equals("accept"); assert ((CacheEntryCreatedEvent) cl.getEvents().get(1)).getValue().equals("v1"); } }
public void testNotifyCacheEntryCreated() { n.notifyCacheEntryCreated("k", "v1", null, true, ctx, null); n.notifyCacheEntryCreated("k", "v1", null, false, ctx, null); assertTrue(cl.isReceivedPost()); assertTrue(cl.isReceivedPre()); assertEquals(2, cl.getInvocationCount()); assertEquals(mockCache, cl.getEvents().get(0).getCache()); assertEquals(Event.Type.CACHE_ENTRY_CREATED, cl.getEvents().get(0).getType()); assertEquals("k", ((CacheEntryCreatedEvent) cl.getEvents().get(0)).getKey()); assertEquals(getExpectedEventValue("k", null, Event.Type.CACHE_ENTRY_CREATED), ((CacheEntryEvent) cl.getEvents().get(0)).getValue()); assertEquals(mockCache, cl.getEvents().get(1).getCache()); assertEquals(Event.Type.CACHE_ENTRY_CREATED, cl.getEvents().get(1).getType()); assertEquals("k", ((CacheEntryCreatedEvent) cl.getEvents().get(1)).getKey()); assertEquals(getExpectedEventValue("k", "v1", Event.Type.CACHE_ENTRY_CREATED), ((CacheEntryEvent) cl.getEvents().get(1)).getValue()); }
private void insertKeyValueAndVerifyListenerNotifications(Collection<CacheListener> listeners) { cache.put("key", "value"); int i = 1; for (CacheListener listener : listeners) { assertEquals("Listener" + i + "failed", 2, listener.getEvents().size()); Event event = listener.getEvents().get(0); assertEquals("Listener" + i + "failed", Event.Type.CACHE_ENTRY_CREATED, event.getType()); CacheEntryCreatedEvent createdEvent = (CacheEntryCreatedEvent) event; assertTrue("Listener" + i + "failed", createdEvent.isPre()); assertEquals("Listener" + i + "failed", "key", createdEvent.getKey()); assertEquals("Listener" + i + "failed", "null-listener-" + i, createdEvent.getValue()); event = listener.getEvents().get(1); assertEquals("Listener" + i + "failed", Event.Type.CACHE_ENTRY_CREATED, event.getType()); createdEvent = (CacheEntryCreatedEvent) event; assertFalse("Listener" + i + "failed", createdEvent.isPre()); assertEquals("Listener" + i + "failed", "key", createdEvent.getKey()); assertEquals("Listener" + i + "failed", "value-listener-" + i,createdEvent.getValue()); ++i; } } }
@CacheEntryCreated public void userCreated(CacheEntryCreatedEvent<String, CachedUser> event) { if (!event.isPre()) { CachedUser user; // Try optimized version if available if (isNewInfinispan) { user = event.getValue(); } else { String userId = event.getKey(); user = event.getCache().get(userId); } if (user != null) { String realm = user.getRealm(); usernameLookup.put(realm, user.getUsername(), user.getId()); if (user.getEmail() != null) { emailLookup.put(realm, user.getEmail(), user.getId()); } log.tracev("User added realm={0}, id={1}, username={2}", realm, user.getId(), user.getUsername()); } } }