Search in sources :

Example 16 with CacheKey

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

the class MergingTransformerConfigurationSource method getCacheKey.

/* (non-Javadoc)
     * @see org.apereo.portal.rendering.xslt.TransformerConfigurationSource#getTransformerConfigurationKey(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
@Override
public CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
    final CacheKeyBuilder cacheKeyBuilder = CacheKey.builder(this.getClass().getName());
    for (final TransformerConfigurationSource source : this.sources) {
        final CacheKey key = source.getCacheKey(request, response);
        cacheKeyBuilder.add(key);
    }
    return cacheKeyBuilder.build();
}
Also used : CacheKeyBuilder(org.apereo.portal.utils.cache.CacheKey.CacheKeyBuilder) CacheKey(org.apereo.portal.utils.cache.CacheKey)

Example 17 with CacheKey

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

the class JpaAggregatedPortletLookupDao method getMappedPortletForFname.

@OpenEntityManager(unitName = BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME)
@Override
public AggregatedPortletMapping getMappedPortletForFname(final String fname) {
    final CacheKey key = CacheKey.build(this.getClass().getName(), fname);
    AggregatedPortletMapping portletMapping = this.entityManagerCache.get(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key);
    if (portletMapping != null) {
        return portletMapping;
    }
    final NaturalIdQuery<AggregatedPortletMappingImpl> query = this.createNaturalIdQuery(AggregatedPortletMappingImpl.class);
    query.using(AggregatedPortletMappingImpl_.fname, fname);
    portletMapping = query.load();
    if (portletMapping != null) {
        this.entityManagerCache.put(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key, portletMapping);
        return portletMapping;
    }
    return this.getTransactionOperations().execute(new TransactionCallback<AggregatedPortletMapping>() {

        @Override
        public AggregatedPortletMapping doInTransaction(TransactionStatus status) {
            final IPortletDefinition portletDefinition = portletDefinitionDao.getPortletDefinitionByFname(fname);
            final String name;
            if (portletDefinition != null) {
                name = portletDefinition.getName();
            } else {
                name = fname;
            }
            final AggregatedPortletMappingImpl aggregatedGroupMapping = new AggregatedPortletMappingImpl(name, fname);
            getEntityManager().persist(aggregatedGroupMapping);
            logger.debug("Created {}", aggregatedGroupMapping);
            entityManagerCache.put(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key, aggregatedGroupMapping);
            return aggregatedGroupMapping;
        }
    });
}
Also used : TransactionStatus(org.springframework.transaction.TransactionStatus) CacheKey(org.apereo.portal.utils.cache.CacheKey) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition) OpenEntityManager(org.apereo.portal.jpa.OpenEntityManager)

Example 18 with CacheKey

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

the class JpaAggregatedTabLookupDao method getTabMapping.

@OpenEntityManager(unitName = BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME)
@Override
public AggregatedTabMapping getTabMapping(final String fragmentName, final String tabName) {
    final CacheKey key = CacheKey.build(this.getClass().getName(), tabName);
    AggregatedTabMapping tabMapping = this.entityManagerCache.get(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key);
    if (tabMapping != null) {
        return tabMapping;
    }
    final NaturalIdQuery<AggregatedTabMappingImpl> query = this.createNaturalIdQuery(AggregatedTabMappingImpl.class);
    query.using(AggregatedTabMappingImpl_.fragmentName, fragmentName);
    query.using(AggregatedTabMappingImpl_.tabName, tabName);
    tabMapping = query.load();
    if (tabMapping != null) {
        this.entityManagerCache.put(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key, tabMapping);
        return tabMapping;
    }
    return this.getTransactionOperations().execute(new TransactionCallback<AggregatedTabMapping>() {

        @Override
        public AggregatedTabMapping doInTransaction(TransactionStatus status) {
            final AggregatedTabMappingImpl aggregatedGroupMapping = new AggregatedTabMappingImpl(fragmentName, tabName);
            getEntityManager().persist(aggregatedGroupMapping);
            logger.debug("Created {}", aggregatedGroupMapping);
            entityManagerCache.put(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key, aggregatedGroupMapping);
            return aggregatedGroupMapping;
        }
    });
}
Also used : TransactionStatus(org.springframework.transaction.TransactionStatus) CacheKey(org.apereo.portal.utils.cache.CacheKey) OpenEntityManager(org.apereo.portal.jpa.OpenEntityManager)

Example 19 with CacheKey

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

the class JsonWrapperFilteringCharacterPipelineComponentTest method testGetCacheKey.

@Test
public void testGetCacheKey() {
    jsonWrapperFilteringCharacterPipelineComponent.setWrappedComponent(wrappedComponent);
    Mockito.when(wrappedComponent.getCacheKey(req, res)).thenReturn(Mockito.mock(CacheKey.class));
    CacheKey cacheKey = jsonWrapperFilteringCharacterPipelineComponent.getCacheKey(req, res);
    Assert.assertNotNull(cacheKey);
}
Also used : CacheKey(org.apereo.portal.utils.cache.CacheKey) Test(org.junit.Test)

Example 20 with CacheKey

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

the class OpenEntityManagerAspect method getEntityManagerFactory.

/**
 * Get the EntityManagerFactory that this filter should use.
 *
 * @return the EntityManagerFactory to use
 * @see #lookupEntityManagerFactory(OpenEntityManager)
 */
protected EntityManagerFactory getEntityManagerFactory(OpenEntityManager openEntityManager) {
    final CacheKey key = this.createEntityManagerFactoryKey(openEntityManager);
    EntityManagerFactory emf = this.entityManagerFactories.get(key);
    if (emf == null) {
        emf = this.lookupEntityManagerFactory(openEntityManager);
        this.entityManagerFactories.put(key, emf);
    }
    return emf;
}
Also used : EntityManagerFactory(javax.persistence.EntityManagerFactory) 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