Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2003-2010 Terracotta, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package net.sf.ehcache.constructs.nonstop;
Concrete factory for creating NonStopCache decorators using ehcache.xml

It is mandatory to specify properties when configuring NonStopCacheDecoratorFactory in ehcache.xml. List of all the properties supported by NonStopCacheDecoratorFactory and corresponding valid values are:

  • name : any string name for the NonStopCache. This property is mandatory.
  • timeoutMillis : Any number for use as the timeout time in milliseconds before timing out for any operation. After operation times out, behavior as specified by timeoutBehavior happens. This property is optional and uses a default value if not specified.
  • timeoutBehavior : {exception | noop | localReads}. This property is optional and uses a default value if not specified.
  • immediateTimeout = {true | false}. This property is optional and uses a default value if not specified.
The default values for the optional properties are:
  • timeoutMillis = 5000
  • timeoutBehavior = exception
  • immediateTimeout = true
Example sample config:
 <cache>
 ...
 <cacheDecoratorFactory
 class="net.sf.ehcache.constructs.nonstop.NonStopCacheDecoratorFactory"
 properties="name=myNonStopCacheName, timeoutMillis=1000, timeoutBehavior=exception, immediateTimeout=true" />
 ...
 </cache>
 

Author(s):
Abhishek Sanoujam
public class NonStopCacheDecoratorFactory extends CacheDecoratorFactory {

    
    @Override
    public Ehcache createDecoratedEhcache(Ehcache cacheProperties properties) {
        if (properties == null) {
            throw new CacheException(NonStopCacheDecoratorFactory.class.getName() + " cannot be used without any configuration properties");
        }
        String name = properties.getProperty("name");
        if (name == null || name.trim().length() == 0) {
            throw new CacheException("NonStopCacheDecoratorFactory needs to be configured with a mandatory 'name' property");
        }
        return new NonStopCache(cachenameproperties);
    }
New to GrepCode? Check out our FAQ X