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;
 
 
Implementation of NonStopCacheConfig

Author(s):
Abhishek Sanoujam
 
 public class NonStopCacheConfigImpl implements NonStopCacheConfig {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(NonStopCacheConfigImpl.class);
     private static final Properties DEFAULT_VALUES_PROPERTIES = new Properties();
 
     private long timeoutMillis;
     private boolean immediateTimeout;
     private NonStopCacheBehaviorType timeoutBehaviorType;

    
Default constructor. Uses default values defined in NonStopCacheConfig
 
     public NonStopCacheConfigImpl() {
         this();
     }

    
Constructor accepting a java.util.Properties that contains mappings for the NonStopCacheConfig. See NonStopCacheConfig for allowed key and values.

For all config keys whose value is not specified in the Properties mapping, the default value will be used. If the value is specified and is not a legal value, exception will be thrown

Parameters:
properties
 
     public NonStopCacheConfigImpl(final Properties properties) {
         this. = getLong(properties);
     }
 
     static {
     }
 
     private NonStopCacheBehaviorType getTimeoutBehavior(Properties propertiesString keyNonStopCacheBehaviorType defaultValue) {
         String value = properties.getProperty(key);
         if (value == null) {
             .info("No value was specified for key '" + key + "'. Using default value - '" + defaultValue.getConfigPropertyName()
                     + "'");
             return defaultValue;
         }
         return NonStopCacheBehaviorType.getTypeFromConfigPropertyName(value);
     }
 
     private static boolean getBoolean(final Properties propertiesfinal String keyboolean defaultValue) {
         String value = properties.getProperty(key);
         if ("true".equalsIgnoreCase(value)) {
             return true;
         } else if ("false".equalsIgnoreCase(value)) {
             return false;
         } else if (value == null) {
             .info("No value was specified for key '" + key + "'. Using default value - '" + defaultValue + "'");
             return defaultValue;
         } else {
             throw new IllegalArgumentException("Value for '" + key + "' should be either 'true' or 'false' -- " + value);
         }
     }
 
     private static long getLong(final Properties propertiesfinal String keylong defaultValue) {
         String value = properties.getProperty(key);
         if (value == null) {
             .info("No value was specified for key '" + key + "'. Using default value - '" + defaultValue + "'");
             return defaultValue;
         }
         try {
             return Long.parseLong(value);
         } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Value for '" + key + "' is not a number -- " + value);
        }
    }

    
    public long getTimeoutMillis() {
        return ;
    }

    
    public void setTimeoutMillis(final long timeoutMillis) {
        this. = timeoutMillis;
    }

    
    public boolean isImmediateTimeout() {
        return ;
    }

    
    public void setImmediateTimeout(final boolean immediateTimeout) {
        this. = immediateTimeout;
    }

    
        return this.;
    }

    
    public void setTimeoutBehaviorType(final NonStopCacheBehaviorType timeoutBehaviorType) {
        this. = timeoutBehaviorType;
    }
New to GrepCode? Check out our FAQ X