Package com.volantis.cache

Examples of com.volantis.cache.Cache


            urlContentCacheConfiguration =
                new URLContentCacheConfiguration(configuration);
            configuration.storeConfiguration(URLContentCacheConfiguration.class,
                urlContentCacheConfiguration);
        }
        final Cache cache = urlContentCacheConfiguration.getCache();

        final URLContentManagerConfiguration managerConfig =
            new URLContentManagerConfiguration();
        managerConfig.setDefaultTimeout(timeout);
        managerConfig.setCache(cache);
View Full Code Here


        final CacheProcessConfiguration cpc = new CacheProcessConfiguration();
        final String cacheName = "cache";
        cpc.createCache(cacheName, "10", "0");

        final Cache cache = cpc.getCache("cache");

        AsyncResult async = cache.asyncQuery(cacheKey, Period.inSeconds(30));

        assertFalse(async.isReady());

        CacheEntry entry = async.getEntry();
        assertNotNull(entry);

        final SystemClock clock = SystemClock.getDefaultInstance();
        ProviderResult result = new ProviderResult(new Integer(1),
            cache.getRootGroup(), true,
            new PipelineCacheState(
                clock.getCurrentTime().addPeriod(Period.inSeconds(2))));
        async.update(result);

        CacheableObjectProvider cacheableObjectProvider =
            new ExpiredObjectsRemainExpiredCacheableObjectProvider(cache.getRootGroup());
        assertNotNull("Integer object is retrievable via the cache",
                cache.retrieve(cacheKey, cacheableObjectProvider));

        Thread.sleep(3000);

        // Slightly messy.
        // Done this way so that we don't get a NullPointerException, and have
        // to do the code below. Both ways are a little messy in that they know
        // a bit too much about the internals.
        //
        // try {
        //      cache.retrieve(cacheKey);
        //      fail("Should throw a NullPointerException when the cache "
        //          + "doesn't contain the object and falls back to the null "
        //          + "provider");
        // } catch (NullPointerException expected) {
        //         // expected
        // }
        assertNull("object has expired from cache and the provider doesn't "
                + "put it back in",
                cache.retrieve(cacheKey, cacheableObjectProvider));

    }
View Full Code Here

    public void testCreateAndGetCache() throws Exception {
        CacheProcessConfiguration cacheProcessConfiguration =
                new CacheProcessConfiguration();
        cacheProcessConfiguration.createCache("myCache", "12345", "0");
       
        Cache cache = cacheProcessConfiguration.getCache("myCache");

        assertNotNull("Cache 'myCache' should exist", cache);
    }
View Full Code Here

        // in a CachingPluggableHTTPManager.
        if (protocol == null || !protocol.startsWith(SECURE_PROTOCOL_PREFIX)) {
            // Default to using caching implementation otherwise.
            if (cachingPluggableHTTPManager == null) {
                // if there is a cache configuration then set up http caching
                final Cache cache = getCache(pipelineConfig);
                if (cache != null) {
                    cachingPluggableHTTPManager =
                        new CachingPluggableHTTPManager(
                            (AbstractPluggableHTTPManager)
                                httpsPluggableHTTPManager, cache);
View Full Code Here

     * @param pipelineConfiguration the pipeline configuration to read the cache
     * from
     * @return the cache stored in the specified pipeline configuration
     */
    private Cache getCache(XMLPipelineConfiguration pipelineConfiguration) {
        final Cache cache;
        if (pipelineConfiguration != null) {
            // get the cache configuration
            URLContentCacheConfiguration urlContentCacheConfiguration =
                (URLContentCacheConfiguration) pipelineConfiguration.
                    retrieveConfiguration(URLContentCacheConfiguration.class);
View Full Code Here

                    (CacheProcessConfiguration) dynamicProcess.getPipelineContext().
                            getPipelineConfiguration().
                            retrieveConfiguration(CacheProcessConfiguration.class);

            final String cacheName = properties.getCacheName();
            final Cache cache = cpc.getCache(cacheName);

            // if properties is null then cacheBody element is used outside
            // cache element or cache element has key attribute set, so
            // recording process has been already started.
            CacheBodyOperationProcess operation =
View Full Code Here

     * @return the created content manager
     */
    private URLContentManager createURLContentManager(final SystemClock clock,
            final Period timeout, final boolean cacheable, final int maxCount) {

        Cache cache = null;
        if (cacheable) {
            final CacheBuilder cacheBuilder =
                CacheFactory.getDefaultInstance().createCacheBuilder();
            cacheBuilder.setMaxCount(maxCount);
            cacheBuilder.setClock(clock);
View Full Code Here

        CacheableObjectProvider objectProvider = new TestCacheableObjectProvider();

        CacheBuilder builder = new CacheBuilderImpl();
        builder.setObjectProvider(objectProvider);
        builder.setMaxCount(8);
        Cache cache = builder.buildCache();

        GroupBuilder groupBuilder = new GroupBuilderImpl();
        groupBuilder.setMaxCount(4);
        Group root = cache.getRootGroup();
        root.addRemovalListener(listenerRootMock);
        Group group1 = root.addGroup("group1", groupBuilder);
        group1.addRemovalListener(listener1Mock);
        Group group2 = root.addGroup("group2", groupBuilder);
        group2.addRemovalListener(listener2Mock);
View Full Code Here

        if (cacheName == null || cacheName.length() == 0) {
            forwardError(dynamicProcess, "Cache name must be specified");
        }


        final Cache cache = cpc.getCache(cacheName);
        if (cache != null) {

            if (cacheKeyString != null) {
                // <cache name="cacheName" key="cacheKey">...
                // cacheInfo element is not expected
View Full Code Here

        String value = "value for (" + entry.getKey() + ")";
        return new ProviderResult(value, selectGroup(entry), true, null);
    }

    private Group selectGroup(CacheEntry entry) {
        Cache cache = entry.getCache();
        String key = (String) entry.getKey();
        int index = key.indexOf('.');
        if (index == -1) {
            throw new IllegalArgumentException(
                    "Invalid key '" + key + "'");
        }

        String group = key.substring(0, index);
        Group root = cache.getRootGroup();
        return root.getGroup(group);
    }
View Full Code Here

TOP

Related Classes of com.volantis.cache.Cache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.