当前位置: 首页>>代码示例>>Java>>正文


Java CacheImpl类代码示例

本文整理汇总了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");
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:26,代码来源:DeviceAgentServiceTest.java

示例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;
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:37,代码来源:BaseCache.java

示例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);
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:29,代码来源:DeviceAgentServiceTest.java

示例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");
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:38,代码来源:DeviceAgentServiceTest.java

示例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");
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:40,代码来源:DeviceAgentServiceTest.java

示例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");
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:41,代码来源:DeviceAgentServiceTest.java

示例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");
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:28,代码来源:DeviceAgentServiceTest.java

示例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");
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:28,代码来源:DeviceAgentServiceTest.java

示例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");
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:28,代码来源:DeviceAgentServiceTest.java

示例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);
                }
            }
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:38,代码来源:DeviceManagerUtil.java

示例11: setCapacity

import org.wso2.carbon.caching.impl.CacheImpl; //导入依赖的package包/类
public void setCapacity(CacheImpl cache) {
    if (getCapacity() > 0) {
        cache.setCapacity(getCapacity());
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:6,代码来源:BaseCache.java

示例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;
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:52,代码来源:BaseCache.java


注:本文中的org.wso2.carbon.caching.impl.CacheImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。