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();
}
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;
}
});
}
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;
}
});
}
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);
}
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;
}
Aggregations