本文整理汇总了Java中org.wso2.carbon.caching.impl.CacheImpl类的典型用法代码示例。如果您正苦于以下问题:Java CacheImpl类的具体用法?Java CacheImpl怎么用?Java CacheImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CacheImpl类属于org.wso2.carbon.caching.impl包,在下文中一共展示了CacheImpl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPublishEventsWithAxisFault
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
@Test(description = "Test Publish events with Axis Fault.")
public void testPublishEventsWithAxisFault() throws DeviceAccessAuthorizationException {
PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toThrow(new AxisFault(""));
Map<String, Object> payload = new HashMap<>();
CacheImpl cache = Mockito.mock(CacheImpl.class);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDynamicEventCache"))
.toReturn(cache);
Response response = this.deviceAgentService.publishEvents(payload, TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
List<Object> payloadList = new ArrayList<>();
Response response2 = this.deviceAgentService.publishEvents(payloadList, TEST_DEVICE_TYPE,
TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response2, "Response should not be null");
Assert.assertEquals(response2.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
}
示例2: getBaseCache
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
private Cache<K, V> getBaseCache() {
Cache<K, V> cache;
CacheManager cacheManager = Caching.getCacheManagerFactory()
.getCacheManager(CACHE_MANAGER_NAME);
if (getCacheTimeout() > 0 && cacheBuilder == null) {
synchronized (cacheName.intern()) {
if (cacheBuilder == null) {
cacheManager.removeCache(cacheName);
cacheBuilder = cacheManager.<K, V>createCacheBuilder(cacheName).
setExpiry(CacheConfiguration.ExpiryType.ACCESSED,
new CacheConfiguration
.Duration(TimeUnit.SECONDS, getCacheTimeout())).
setExpiry(CacheConfiguration.ExpiryType.MODIFIED,
new CacheConfiguration
.Duration(TimeUnit.SECONDS, getCacheTimeout())).
setStoreByValue(false);
cache = cacheBuilder.build();
setCapacity((CacheImpl) cache);
} else {
cache = cacheManager.getCache(cacheName);
setCapacity((CacheImpl) cache);
}
}
} else {
cache = cacheManager.getCache(cacheName);
setCapacity((CacheImpl) cache);
}
return cache;
}
示例3: testEventPublishWithNullEventAttributesAndNullEventStreamDefDAO
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
@Test(description = "Test event publishing when the event stream dao is null.")
public void testEventPublishWithNullEventAttributesAndNullEventStreamDefDAO()
throws DeviceAccessAuthorizationException, RemoteException {
PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toReturn(this.eventStreamAdminServiceStub);
Mockito.when(this.eventStreamAdminServiceStub.getStreamDefinitionDto(Mockito.anyString())).thenReturn(null);
Map<String, Object> payload = new HashMap<>();
CacheImpl cache = Mockito.mock(CacheImpl.class);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDynamicEventCache"))
.toReturn(cache);
Response response = this.deviceAgentService.publishEvents(payload, TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(),
"The response status should be 400");
List<Object> payloadList = new ArrayList<>();
Response response2 = this.deviceAgentService.publishEvents(payloadList, TEST_DEVICE_TYPE,
TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response2, "Response should not be null");
Assert.assertEquals(response2.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(),
"The response status should be 400");
Mockito.reset(eventStreamAdminServiceStub);
}
示例4: testEventPublishWithEventAttributesNULLAndPublishEventsFailure
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
@Test(description = "Test the error scenario of Publishing Events with null event attributes.")
public void testEventPublishWithEventAttributesNULLAndPublishEventsFailure() throws
DeviceAccessAuthorizationException, RemoteException {
PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toReturn(this.eventStreamAdminServiceStub);
EventStreamAttributeDto eventStreamAttributeDto = Mockito.mock(EventStreamAttributeDto.class,
Mockito.RETURNS_MOCKS);
EventStreamDefinitionDto eventStreamDefinitionDto = Mockito.mock(EventStreamDefinitionDto.class,
Mockito.RETURNS_MOCKS);
Mockito.when(this.eventStreamAdminServiceStub.getStreamDefinitionDto(Mockito.anyString()))
.thenReturn(eventStreamDefinitionDto);
Mockito.when(eventStreamDefinitionDto.getPayloadData()).thenReturn(new EventStreamAttributeDto[]{});
EventsPublisherService eventPublisherService = Mockito.mock(EventsPublisherServiceImpl.class,
Mockito.RETURNS_MOCKS);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventPublisherService"))
.toReturn(eventPublisherService);
Map<String, Object> payload = new HashMap<>();
CacheImpl cache = Mockito.mock(CacheImpl.class);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDynamicEventCache"))
.toReturn(cache);
Response response = this.deviceAgentService.publishEvents(payload, TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
List<Object> payloadList = new ArrayList<>();
Response response2 = this.deviceAgentService.publishEvents(payloadList, TEST_DEVICE_TYPE,
TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response2, "Response should not be null");
Assert.assertEquals(response2.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
}
示例5: testEventPublishWithEventAttributesNULLAndPublishEventsSuccess
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
@Test(description = "Test Event publishing success scenario.")
public void testEventPublishWithEventAttributesNULLAndPublishEventsSuccess()
throws DeviceAccessAuthorizationException, RemoteException, DataPublisherConfigurationException {
PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toReturn(this.eventStreamAdminServiceStub);
EventStreamAttributeDto eventStreamAttributeDto = Mockito.mock(EventStreamAttributeDto.class,
Mockito.RETURNS_MOCKS);
EventStreamDefinitionDto eventStreamDefinitionDto = Mockito.mock(EventStreamDefinitionDto.class,
Mockito.RETURNS_MOCKS);
Mockito.when(this.eventStreamAdminServiceStub.getStreamDefinitionDto(Mockito.anyString()))
.thenReturn(eventStreamDefinitionDto);
Mockito.when(eventStreamDefinitionDto.getPayloadData()).thenReturn(new EventStreamAttributeDto[]{});
EventsPublisherService eventPublisherService = Mockito.mock(EventsPublisherServiceImpl.class,
Mockito.RETURNS_MOCKS);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventPublisherService"))
.toReturn(eventPublisherService);
Mockito.when(eventPublisherService.publishEvent(Mockito.anyString(), Mockito.anyString(), Mockito.any(),
Mockito.any(), Mockito.any())).thenReturn(true);
Map<String, Object> payload = new HashMap<>();
CacheImpl cache = Mockito.mock(CacheImpl.class);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDynamicEventCache"))
.toReturn(cache);
Response response = this.deviceAgentService.publishEvents(payload, TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(),
"The response status should be 200");
List<Object> payloadList = new ArrayList<>();
Response response2 = this.deviceAgentService.publishEvents(payloadList,
TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response2, "Response should not be null");
Assert.assertEquals(response2.getStatus(), Response.Status.OK.getStatusCode(),
"The response status should be 200");
}
示例6: testPublishEventsDataPublisherConfigurationException
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
@Test(description = "Test event publishing when PublishEvents throws DataPublisherConfigurationException.")
public void testPublishEventsDataPublisherConfigurationException() throws DeviceAccessAuthorizationException,
RemoteException, DataPublisherConfigurationException {
PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toReturn(this.eventStreamAdminServiceStub);
EventStreamAttributeDto eventStreamAttributeDto = Mockito.mock(EventStreamAttributeDto.class,
Mockito.RETURNS_MOCKS);
EventStreamDefinitionDto eventStreamDefinitionDto = Mockito.mock(EventStreamDefinitionDto.class,
Mockito.RETURNS_MOCKS);
Mockito.when(this.eventStreamAdminServiceStub.getStreamDefinitionDto(Mockito.anyString()))
.thenReturn(eventStreamDefinitionDto);
Mockito.when(eventStreamDefinitionDto.getPayloadData()).thenReturn(new EventStreamAttributeDto[]{});
EventsPublisherService eventPublisherService = Mockito.mock(EventsPublisherServiceImpl.class,
Mockito.RETURNS_MOCKS);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventPublisherService"))
.toReturn(eventPublisherService);
Mockito.when(eventPublisherService.publishEvent(Mockito.anyString(), Mockito.anyString(), Mockito.any(),
Mockito.any(), Mockito.any())).thenThrow(
new DataPublisherConfigurationException("meta data[0] should have the device Id field"));
Map<String, Object> payload = new HashMap<>();
CacheImpl cache = Mockito.mock(CacheImpl.class);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDynamicEventCache"))
.toReturn(cache);
Response response = this.deviceAgentService.publishEvents(payload, TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
List<Object> payloadList = new ArrayList<>();
Response response2 = this.deviceAgentService.publishEvents(payloadList, TEST_DEVICE_TYPE,
TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response2, "Response should not be null");
Assert.assertEquals(response2.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
}
示例7: testPublishEventsWithRemoteException
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
@Test(description = "Test Publishing events when EventStreamAdminService throws Remote exception.")
public void testPublishEventsWithRemoteException() throws DeviceAccessAuthorizationException {
PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toThrow(new RemoteException());
Map<String, Object> payload = new HashMap<>();
CacheImpl cache = Mockito.mock(CacheImpl.class);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDynamicEventCache"))
.toReturn(cache);
Response response = this.deviceAgentService.publishEvents(payload, TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
List<Object> payloadList = new ArrayList<>();
Response response2 = this.deviceAgentService.publishEvents(payloadList, TEST_DEVICE_TYPE,
TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response2, "Response should not be null");
Assert.assertEquals(response2.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
}
示例8: testPublishEventsWithJWTException
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
@Test(description = "Test Publishing events when EventStreamAdminService throws JWT exception.")
public void testPublishEventsWithJWTException() throws DeviceAccessAuthorizationException {
PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toThrow(new JWTClientException());
Map<String, Object> payload = new HashMap<>();
CacheImpl cache = Mockito.mock(CacheImpl.class);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDynamicEventCache"))
.toReturn(cache);
Response response = this.deviceAgentService.publishEvents(payload, TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
List<Object> payloadList = new ArrayList<>();
Response response2 = this.deviceAgentService.publishEvents(payloadList, TEST_DEVICE_TYPE,
TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response2, "Response should not be null");
Assert.assertEquals(response2.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
}
示例9: testPublishEventsWithUserStoreException
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
@Test(description = "Test Publishing events when EventStreamAdminService throws User Store exception.")
public void testPublishEventsWithUserStoreException() throws DeviceAccessAuthorizationException {
PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
.toReturn(this.privilegedCarbonContext);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class,
"getDeviceAccessAuthorizationService")).toReturn(this.deviceAccessAuthorizationService);
Mockito.when(this.deviceAccessAuthorizationService.isUserAuthorized(Mockito.any(DeviceIdentifier.class)))
.thenReturn(true);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getEventStreamAdminServiceStub"))
.toThrow(new UserStoreException());
Map<String, Object> payload = new HashMap<>();
CacheImpl cache = Mockito.mock(CacheImpl.class);
PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDynamicEventCache"))
.toReturn(cache);
Response response = this.deviceAgentService.publishEvents(payload, TEST_DEVICE_TYPE, TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response, "Response should not be null");
Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
List<Object> payloadList = new ArrayList<>();
Response response2 = this.deviceAgentService.publishEvents(payloadList, TEST_DEVICE_TYPE,
TEST_DEVICE_IDENTIFIER);
Assert.assertNotNull(response2, "Response should not be null");
Assert.assertEquals(response2.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
"The response status should be 500");
}
示例10: initializeDeviceCache
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
public static void initializeDeviceCache() {
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
int deviceCacheExpiry = config.getDeviceCacheConfiguration().getExpiryTime();
long deviceCacheCapacity = config.getDeviceCacheConfiguration().getCapacity();
CacheManager manager = getCacheManager();
if (config.getDeviceCacheConfiguration().isEnabled()) {
if(!isDeviceCacheInitialized) {
isDeviceCacheInitialized = true;
if (manager != null) {
if (deviceCacheExpiry > 0) {
manager.<DeviceCacheKey, Device>createCacheBuilder(DeviceManagementConstants.DEVICE_CACHE).
setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS,
deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.
Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build();
if(deviceCacheCapacity > 0 ) {
((CacheImpl)(manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE))).
setCapacity(deviceCacheCapacity);
}
} else {
manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
}
} else {
if (deviceCacheExpiry > 0) {
Caching.getCacheManager().
<DeviceCacheKey, Device>createCacheBuilder(DeviceManagementConstants.DEVICE_CACHE).
setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS,
deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.
Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build();
((CacheImpl)(manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE))).
setCapacity(deviceCacheCapacity);
} else {
Caching.getCacheManager().<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
}
}
}
}
}
示例11: setCapacity
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
public void setCapacity(CacheImpl cache) {
if (getCapacity() > 0) {
cache.setCapacity(getCapacity());
}
}
示例12: getBaseCache
import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
private Cache<K, V> getBaseCache() {
Cache<K, V> cache = null;
try {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
CacheManager cacheManager = Caching.getCacheManagerFactory()
.getCacheManager(CACHE_MANAGER_NAME);
if (getCacheTimeout() > 0 && cacheBuilder == null) {
synchronized (cacheName.intern()) {
if (cacheBuilder == null) {
cacheManager.removeCache(cacheName);
cacheBuilder = cacheManager.<K, V>createCacheBuilder(cacheName).
setExpiry(CacheConfiguration.ExpiryType.ACCESSED,
new CacheConfiguration
.Duration(TimeUnit.SECONDS, getCacheTimeout())).
setExpiry(CacheConfiguration.ExpiryType.MODIFIED,
new CacheConfiguration
.Duration(TimeUnit.SECONDS, getCacheTimeout())).
setStoreByValue(false);
cache = cacheBuilder.build();
for (AbstractCacheListener cacheListener : cacheListeners) {
if (cacheListener.isEnable()) {
this.cacheBuilder.registerCacheEntryListener(cacheListener);
}
}
setCapacity((CacheImpl) cache);
} else {
cache = cacheManager.getCache(cacheName);
setCapacity((CacheImpl) cache);
}
}
} else {
cache = cacheManager.getCache(cacheName);
setCapacity((CacheImpl) cache);
}
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
return cache;
}