當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。