Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *    Copyright 2012 The MyBatis Team
   *
   *    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 org.mybatis.caches.memcached;
 
 import java.util.List;
Converter from the Config to a proper MemcachedConfiguration.

Version:
$Id: MemcachedConfigurationBuilder.java 5217 2012-04-23 19:59:07Z simonetripodi $
 
 final class MemcachedConfigurationBuilder {

    
This class instance.
 
     private static final MemcachedConfigurationBuilder INSTANCE = new MemcachedConfigurationBuilder();

    
 
     private static final String MEMCACHED_RESOURCE = "memcached.properties";

    
Return this class instance.

Returns:
this class instance.
 
     public static MemcachedConfigurationBuilder getInstance() {
         return ;
     }

    
The setters used to extract properties.
 
     private final List<AbstractPropertySetter<?>> settersRegistry = new ArrayList<AbstractPropertySetter<?>>();

    
Hidden constructor, this class can't be instantiated.
 
     private MemcachedConfigurationBuilder() {
         .add(new StringPropertySetter("org.mybatis.caches.memcached.keyprefix""keyPrefix""_mybatis_"));
 
         .add(new IntegerPropertySetter("org.mybatis.caches.memcached.expiration""expiration", 60 * 60 * 24 * 30));
         .add(new IntegerPropertySetter("org.mybatis.caches.memcached.timeout""timeout", 5));
         .add(new TimeUnitSetter());
 
         .add(new BooleanPropertySetter("org.mybatis.caches.memcached.asyncget""usingAsyncGet"false));
         .add(new BooleanPropertySetter("org.mybatis.caches.memcached.compression""compressionEnabled"false));
 
         .add(new ConnectionFactorySetter());
     }

    
Parses the Config and builds a new MemcachedConfiguration.

Returns:
the converted MemcachedConfiguration.
 
         return parseConfiguration(getClass().getClassLoader());
     }

    
Parses the Config and builds a new MemcachedConfiguration.

Parameters:
the java.lang.ClassLoader used to load the memcached.properties file in classpath.
Returns:
the converted MemcachedConfiguration.
 
     public MemcachedConfiguration parseConfiguration(ClassLoader classLoader) {
         Properties config = new Properties();
 
         // load the properties specified from /memcached.properties, if present
         InputStream input = classLoader.getResourceAsStream();
         if (input != null) {
             try {
                 config.load(input);
             } catch (IOException e) {
                 throw new RuntimeException("An error occurred while reading classpath property '"
                         + 
                         + "', see nested exceptions"e);
             } finally {
                try {
                    input.close();
                } catch (IOException e) {
                    // close quietly
                }
            }
        }
        MemcachedConfiguration memcachedConfiguration = new MemcachedConfiguration();
        for (AbstractPropertySetter<?> setter : ) {
            setter.set(configmemcachedConfiguration);
        }
        return memcachedConfiguration;
    }
New to GrepCode? Check out our FAQ X