Search in sources :

Example 11 with CacheKey

use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.

the class CachingStAXPipelineComponentTest method testCacheHit.

@Test
public void testCacheHit() {
    final MockHttpServletRequest mockReq = new MockHttpServletRequest();
    final MockHttpServletResponse mockRes = new MockHttpServletResponse();
    final CacheKey cacheKey = CacheKey.build("testCacheKey");
    final CachedEventReader<XMLEvent> eventReader = new CachedEventReader<XMLEvent>(Collections.EMPTY_LIST, Collections.EMPTY_MAP);
    final Element cacheElement = new Element(cacheKey, eventReader);
    final Ehcache cache = createMock(Ehcache.class);
    final StAXPipelineComponent targetComponent = createMock(StAXPipelineComponent.class);
    final ResourcesElementsProvider elementsProvider = createMock(ResourcesElementsProvider.class);
    expect(elementsProvider.getDefaultIncludedType()).andReturn(Included.AGGREGATED);
    expect(targetComponent.getCacheKey(mockReq, mockRes)).andReturn(cacheKey);
    expect(cache.get(cacheKey)).andReturn(cacheElement);
    replay(cache, targetComponent, elementsProvider);
    final CachingStAXPipelineComponent cachingComponent = new CachingStAXPipelineComponent();
    cachingComponent.setCache(cache);
    cachingComponent.setWrappedComponent(targetComponent);
    cachingComponent.setResourcesElementsProvider(elementsProvider);
    final PipelineEventReader<XMLEventReader, XMLEvent> actualEventReader = cachingComponent.getEventReader(mockReq, mockRes);
    Assert.assertNotNull(actualEventReader);
    Assert.assertNotNull(actualEventReader.getEventReader());
    Assert.assertFalse(actualEventReader.getEventReader().hasNext());
    verify(cache, targetComponent, elementsProvider);
}
Also used : StAXPipelineComponent(org.apereo.portal.rendering.StAXPipelineComponent) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Element(net.sf.ehcache.Element) ResourcesElementsProvider(org.jasig.resourceserver.utils.aggr.ResourcesElementsProvider) XMLEvent(javax.xml.stream.events.XMLEvent) Ehcache(net.sf.ehcache.Ehcache) XMLEventReader(javax.xml.stream.XMLEventReader) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) CacheKey(org.apereo.portal.utils.cache.CacheKey) Test(org.junit.Test)

Example 12 with CacheKey

use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.

the class LayoutCachingService method cacheLayout.

@Override
public void cacheLayout(IPerson owner, IUserProfile profile, DistributedUserLayout layout) {
    final CacheKey cacheKey = this.getCacheKey(owner, profile);
    this.layoutCache.put(new Element(cacheKey, layout));
}
Also used : Element(net.sf.ehcache.Element) CacheKey(org.apereo.portal.utils.cache.CacheKey)

Example 13 with CacheKey

use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.

the class LayoutCachingService method removeCachedLayout.

@Override
public void removeCachedLayout(IPerson owner, IUserProfile profile) {
    final CacheKey cacheKey = this.getCacheKey(owner, profile);
    this.layoutCache.remove(cacheKey);
}
Also used : CacheKey(org.apereo.portal.utils.cache.CacheKey)

Example 14 with CacheKey

use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.

the class StAXAttributeIncorporationComponent method getCacheKey.

/* (non-Javadoc)
     * @see org.apereo.portal.rendering.PipelineComponent#getCacheKey(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
@Override
public CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
    final CacheKey parentKey = this.wrappedComponent.getCacheKey(request, response);
    final CacheKey attributeKey = this.attributeSource.getCacheKey(request, response);
    return CacheKey.build(this.beanName, parentKey, attributeKey);
}
Also used : CacheKey(org.apereo.portal.utils.cache.CacheKey)

Example 15 with CacheKey

use of org.apereo.portal.utils.cache.CacheKey in project uPortal by Jasig.

the class XSLTComponent method getCacheKey.

@Override
public CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
    final CacheKey parentCacheKey = this.wrappedComponent.getCacheKey(request, response);
    final CacheKey transformerKey;
    if (transformerSource != null) {
        transformerKey = this.transformerSource.getCacheKey(request, response);
    } else {
        transformerKey = null;
    }
    final CacheKey transformerConfigurationKey;
    if (this.xsltParameterSource != null) {
        transformerConfigurationKey = this.xsltParameterSource.getCacheKey(request, response);
    } else {
        transformerConfigurationKey = null;
    }
    return CacheKey.build(this.beanName, parentCacheKey, transformerKey, transformerConfigurationKey);
}
Also used : CacheKey(org.apereo.portal.utils.cache.CacheKey)

Aggregations

CacheKey (org.apereo.portal.utils.cache.CacheKey)23 Element (net.sf.ehcache.Element)9 Test (org.junit.Test)6 Ehcache (net.sf.ehcache.Ehcache)4 ResourcesElementsProvider (org.jasig.resourceserver.utils.aggr.ResourcesElementsProvider)4 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)4 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)4 OpenEntityManager (org.apereo.portal.jpa.OpenEntityManager)3 PipelineEventReaderImpl (org.apereo.portal.rendering.PipelineEventReaderImpl)3 TransactionStatus (org.springframework.transaction.TransactionStatus)3 Deque (java.util.Deque)2 XMLEventReader (javax.xml.stream.XMLEventReader)2 XMLEvent (javax.xml.stream.events.XMLEvent)2 CharacterEventReader (org.apereo.portal.character.stream.CharacterEventReader)2 CharacterEvent (org.apereo.portal.character.stream.events.CharacterEvent)2 CharacterPipelineComponent (org.apereo.portal.rendering.CharacterPipelineComponent)2 StAXPipelineComponent (org.apereo.portal.rendering.StAXPipelineComponent)2 SimpleCacheEntryTag (org.apereo.portal.utils.cache.SimpleCacheEntryTag)2 Serializable (java.io.Serializable)1 LinkedHashMap (java.util.LinkedHashMap)1