if (isConfigured) { messageLogger.logWarn("setConfig() called on already configured instance."); return;
if (properties == null) throw new IllegalArgumentException("properties cannot be null.");  String cacheConfigProperty = properties.getProperty(CACHE_CONFIG_PROPERTY_NAME);  if (cacheConfigProperty == null) throw new MoriaStoreConfigurationException("Configuration property " + CACHE_CONFIG_PROPERTY_NAME + " must be set.");  String realTTLPercentageProperty = properties.getProperty(REAL_TTL_PERCENTAGE_PROPERTY_NAME);  if (realTTLPercentageProperty == null) throw new MoriaStoreConfigurationException("Configuration property " + REAL_TTL_PERCENTAGE_PROPERTY_NAME + " must be set.");  long realTTLPercentage = Long.parseLong(realTTLPercentageProperty);  if (realTTLPercentage < 1L || realTTLPercentage > 100L) throw new MoriaStoreConfigurationException(REAL_TTL_PERCENTAGE_PROPERTY_NAME + " must be between one and one hundred, inclusive.");  FileInputStream cacheConfigFile;  try { cacheConfigFile = new FileInputStream(cacheConfigProperty); } catch (FileNotFoundException fnnf) { String message = "The configuration file for the store was not found."; throw new MoriaStoreConfigurationException(message, fnnf); }  PropertyConfigurator configurator = new PropertyConfigurator();  try { configurator.configure(store, cacheConfigFile); } catch (Exception e) { throw new MoriaStoreConfigurationException("Unable to configure the cache.", e); }  TicketTTLEvictionPolicy ticketTTLEvictionPolicy = new TicketTTLEvictionPolicy();  try { ticketTTLEvictionPolicy.parseConfig(store.getEvictionPolicyConfig()); } catch (Exception e) { throw new MoriaStoreConfigurationException("Unable to get ticket TTL's from config", e); }  ticketTTLs = new HashMap(); TicketTTLEvictionPolicy.RegionValue regionValues[] = ticketTTLEvictionPolicy.getRegionValues();  for (Iterator ticketTypeIterator = MoriaTicketType.TICKET_TYPES.iterator(); ticketTypeIterator.hasNext();) { Long ttl = null; MoriaTicketType ticketType = (MoriaTicketType) ticketTypeIterator.next();  for (int i = 0; i < regionValues.length; i++) { if (ticketType.toString().equals(regionValues[i].regionName)) { ttl = new Long(regionValues[i].timeToLive * realTTLPercentage / 100L); break; } }  if (ttl == null || ttl.compareTo(new Long(1000L)) < 0) { Object defaultTTL = ticketDefaultTTLs.get(ticketType);  if (defaultTTL == null) throw new NullPointerException("No default value defined for: " + ticketType);  ticketTTLs.put(ticketType, defaultTTL); messageLogger.logCritical("TTL for " + ticketType + " not found.  Using default value. This is not a good thing."); } else { ticketTTLs.put(ticketType, ttl); } }  try { store.start(); } catch (Exception e) { throw new MoriaStoreConfigurationException("Unable to start the cache", e); }  isConfigured = new Boolean(true);
    public void setConfig(final Properties properties) {        /* Return if this cache instance has already been configured once. */        if (isConfigured) {            messageLogger.logWarn("setConfig() called on already configured instance.");            return;        }        /* Throw exception if argument is null. */        if (properties == null) {            throw new IllegalArgumentException("properties cannot be null.");        }        /* Read the the file name from the properties. */        String cacheConfigPropertyName = "no.feide.moria.store.cachestoreconf";        String cacheConfigProperty = properties.getProperty(cacheConfigPropertyName);        if (cacheConfigProperty == null) {            throw new MoriaStoreConfigurationException(cacheConfigPropertyName + " must be set.");        }        /* Open the file. */        FileInputStream cacheConfigFile;        try {            cacheConfigFile = new FileInputStream(cacheConfigProperty);        } catch (FileNotFoundException fnnf) {            String message = "The configuration file for the store was not found.";            throw new MoriaStoreConfigurationException(message, fnnf);        }        /* Configure the cache. */        PropertyConfigurator configurator = new PropertyConfigurator();        try {            configurator.configure(store, cacheConfigFile);        } catch (Exception e) {            String message = "Unable to configure the cache.";            throw new MoriaStoreConfigurationException(message, e);        }        // TODO: Get values from config        loginTicketTTL = new Long(300); /* 5 min */        serviceTicketTTL = new Long(300); /* 5 min */        ssoTicketTTL = new Long(28800); /* 8 hours */        tgTicketTTL = new Long(7200); /* 2 hours */        proxyTicketTTL = new Long(300); /* 5 min */        /* Start the configured cache. */        try {            store.start();        } catch (RuntimeException re) {            throw re;        } catch (Exception e) {            throw new MoriaStoreConfigurationException("Unable to start the cache", e);        }        /* Set the configuration state of this instance to true. */        isConfigured = true;    }